Installing Oracle Java on Ubuntu and Fedora

Reading Time: 1 minute

Description

In this article we will install Oracle’s Java, besides the OpenJDK can be shipped with the package managers in the distros. This way will allow you to end-to-end fully install Oracle JDK. The version I used was against version 8, but you can also use the same way for the other versions as well

Specifications

Ubuntu 18.04 LTS 64 Bit

Oracle Java 8 Update 181

Steps

1. Download the Java from the Oracle’s web site

2. Unpack the tar file

tar zxvf jdk-8u181-linux-x64.tar.gz

3. Create a folder in the usr location

sudo mkdir /usr/java

4. Move all the files from the unzipped location to the newly created folder

sudo mv jdk1.8.0_181/ /usr/java

5. Install all the java commands using the alternatives

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.8.0_181/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.8.0_181/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/jdk1.8.0_181/bin/javaws" 1
sudo update-alternatives --install /usr/bin/jar "jar" "/usr/java/jdk1.8.0_181/bin/jar" 1

6. Fix the permissions for the Java entries

sudo chmod a+x /usr/bin/java 
sudo chmod a+x /usr/bin/javac 
sudo chmod a+x /usr/bin/javaws
sudo chmod a+x /usr/bin/jar
sudo chown -R root:root /usr/java/jdk1.8.0_181

7. Add Java home to the Global Environment

sudo nano /etc/environment

7.1. And add the below line and save

JAVA_HOME=/usr/java/jdk1.8.0_172
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

8. Reflect the Global Environment changes

source /etc/environment
. /etc/environment

9. Check the installation for Java

java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

10. Check the installation for Java Compiler

javac -version
javac 1.8.0_181

11. Check the installation for Java Web Start

javaws -version
Java(TM) Web Start 11.181.2.13-fcs

11. Check the installation for Jar

jar
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
sudo update-alternatives --config jar

Installing and configuring Glassfish 4.1 on RHEL and Centos

Reading Time: 1 minute

cd /opt

wget http://dlc.sun.com.edgesuite.net/glassfish/4.1/release/glassfish-4.1.zip

unzip glassfish-4.1.zip

mv glassfish4 glassfish

create glassfish user

groupadd glassfish
useradd -s /bin/bash -g glassfish glassfish
chown -R glassfish: /opt/glassfish

change the user password

passwd glassfish

nano /etc/init.d/glassfish

add the below line

#!/usr/bin/env bash
# description: Glassfish start/stop/restart
# processname: glassfish
# chkconfig: 2445 20 80
JAVA_HOME=/usr/java/jdk1.7.0_75
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/opt/glassfish
GLASSFISH_USER=glassfish

case $1 in
start)
    su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
stop)
    su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
;;
restart)
    su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
    su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
esac
exit 0

save it

chmod +x /etc/init.d/glassfish

chkconfig --add glassfish

chkconfig glassfish on

reboot

 

cd /opt/glassfish/bin

change admin password

./asadmin --port 4848 change-admin-password

default admin password is empty just push on enter for default password

Enter admin user name [default: admin]>admin
Enter the admin password>
Enter the new admin password>
Enter the new admin password again>
Command change-admin-password executed successfully.

enable remote admin

./asadmin --port 4848 enable-secure-admin

Enter admin user name> admin
Enter admin password for user “admin”>
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

reboot

add the firewall rule

firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=4848/tcp
firewall-cmd --reload

Installing and configuring tomcat on Centos 7

Reading Time: 1 minute

wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz

tar -xvvf apache-tomcat-7.0.57.tar.gz

mv apache-tomcat-7.0.57 /opt/tomcat

nano /opt/tomcat/conf/tomcat-users.xml

find the <tomcat-users> </tomcat-users> lines and in between add the below entry

 <role rolename="manager-gui"/>
 <role rolename="manager-script"/>
 <role rolename="manager-jmx"/>
 <role rolename="manager-status"/>
 <role rolename="admin-gui"/>
 <role rolename="admin-script"/>
 <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

and save the file and then issue command

chmod 755 /opt/tomcat
sh /opt/tomcat/bin/startup.sh

 

Installing and configuring Mysql server on Freebsd

Reading Time: 2 minutes

Go to the /usr folder

cd /usr

and then extract updates

portsnap fetch extract

then go to mysql client folder in ports(the version may change on your ports version and updates)

/usr/ports/databases/mysql56-client

then issue the command to install client

make install clean

and then navigate to the server folder

cd /usr/ports/databases/mysql56-server

then install it

make install clean

and then add the mysql instance to be started in boot

echo 'mysql_enable="YES"' >> /etc/rc.conf

and then start the mysqlserver

/usr/local/etc/rc.d/mysql-server onestart

and then to check whether the service is running issue the below command and if you see below output mysql is up and runnig

root@virtualbsd:/usr/ports/databases/mysql56-server # ps -waux | grep mysql
mysql 27125  0.0  0.0  17064      0  -  IWs  -        0:00.00 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysq
mysql 27235  0.0 62.3 649464 148088  -  S     1:52AM  0:00.90 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf 
root  27243  0.0  0.5  10512   1156  0  RL+   1:52AM  0:00.00 grep mysql

later on issue the following commands

chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/
/usr/local/bin/mysqld_safe –user=mysql &

then we are good to set a new password for the root

/usr/local/bin/mysqladmin -u root password ENTERYOURNEWPASSHERE

and then issue the command for automated post installation settings

mysql_secure_installation

then restart your mysql server

/usr/local/etc/rc.d/mysql-server restart

if you want to access your mysql server from remote carry out following commands

connect to your mysql server

mysql -p

and then grant access to root

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'
IDENTIFIED BY 'YOURPASSWORDHERE' WITH GRANT OPTION;

then issue grant command one more time

GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "YOURPASSWORDHERE";

then flush privileges

flush privileges;

then quit

quit

then restart your mysql server

/usr/local/etc/rc.d/mysql-server restart

then launch mysql workbench and connect to your server

voilà!

freebsdmysqlworkbench

Jdk installation javaws error javaws: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory

Reading Time: 1 minute

javaws -version

[root@centos ~]# javaws: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory
-bash: javaws:: command not found

install this package

yum -y install libX11-devel.x86_64

and then magic happens

[root@centos ~]# javaws -version
Java(TM) Web Start 10.71.2.14-fcs
Usage:  javaws [run-options] <jnlp-file>
        javaws [control-options]

Smaller Eclipse menus on ubuntu

Reading Time: 1 minute

in terminal in your home directory issue the below command

sudo gedit ~/.gtkrc-2.0

and copy the below content and save

style "gtkcompact" { 
  GtkButton::defaultborder={0,0,0,0} 
  GtkButton::defaultoutsideborder={0,0,0,0} 
  GtkButtonBox::childminwidth=0 
  GtkButtonBox::childminheigth=0 
  GtkButtonBox::childinternalpadx=0 
  GtkButtonBox::childinternalpady=0 
  GtkMenu::vertical-padding=1 
  GtkMenuBar::internalpadding=0 
  GtkMenuItem::horizontalpadding=4
  GtkToolbar::internal-padding=0 
  GtkToolbar::space-size=0 
  GtkOptionMenu::indicatorsize=0 
  GtkOptionMenu::indicatorspacing=2 
  GtkPaned::handlesize=4 
  GtkRange::troughborder=0 
  GtkRange::stepperspacing=0 
  GtkScale::valuespacing=0 
  GtkScrolledWindow::scrollbarspacing=0 
  GtkExpander::expandersize=10 
  GtkExpander::expanderspacing=0 
  GtkTreeView::vertical-separator=0 
  GtkTreeView::horizontal-separator=0 
  GtkTreeView::expander-size=8 
  GtkTreeView::fixed-height-mode=TRUE 
  GtkWidget::focuspadding=1 
} 
class "GtkWidget" style "gtkcompact"

style "gtkcompactextra" { 
  xthickness=2 ythickness=2 
} 
class "GtkButton" style "gtkcompactextra"
class "GtkToolbar" style "gtkcompactextra"
class "GtkPaned" style "gtkcompactextra"

if you increase xthickness and ythickness it will make menus bigger so value 2 is fine