.Sh script to install java in a specific location

I am using the following command to install java 8 in my ubuntu 32 bit match. I am using a .sh file to run these commands -

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-set-default

read -t 10

      

It works fine, but I ran into two problems.

  • It sets the default location in a java environment variable (I want to set in my specific directory like home / abc / something and set the enviornment variable to match that)

  • I want to pause the script for 10 seconds at the end to check the console.

I just want to check if my enviornment variable is set or not. I am using this comamnd in my .sh file

export PATH=$PATH:$(pwd)/Linux_32/Software/jdk1.8.0_20/bin 

      

and when i open terminal and check

java -version 

      

It doesn't show me anything, so I need to check if there is something problem with installing java. but every time the .sh terminal is closed

+3


source to share


1 answer


You seem to be trying to run java -version

after the script, but the modified PATH environment variable is not saved outside of the script. They work in different shells. To check, run printenv PATH

and you will notice that the jdk path is not added.



You can try running java -version

in script, or adding jdk to yours PATH

after running script, eg. in .profile

or .bashrc

.

0


source







All Articles