Where to install JDK .tar.gz file on Ubuntu 18.04? - java

Where is the recommended place to install the jdk .tar.gz file I just downloaded? I want it to be available for all users.
The installation guides that I have found told me to extract the jdk in many different places, such as /opt, /usr/lib and /usr/local. But the which one is the "right" choice? Why?

Into /usr/lib/jvm/ folder, the reason is because the default installation path is that one when you use the sudo apt install command, which makes total sense to me.
Example:
OpenJDK 11 is located at : /usr/lib/jvm/java-11-openjdk-amd64/bin/java
OpenJDK 8 is located at : /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
For more information, you can read this article here.

First Download the Oracle JDK Download Oracle JDK or Open JdkDownload Open JDK, then follow these commands :
First Unzip the tar file with this following command
tar zxvf <tar file name>
Like : tar zxvf jdk-11.0.2.jdk
enter your password if asked
Now set the JAVA_HOME i.e system variables to the end of /etc/profile file
first, open /etc/profile : vi /etc/profile
and press I to insert and put this at the end
export JAVA_HOME=<Directory where JAVA has been extracted>
export JAVA_HOME=/home/jdk-10.0.2.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
now press ESC + SHIFT + :WQ to save the changes

For installation from the JDK tar.gz use the following command to unpack the tarball to the desired directory where you need to install java :
tar zxvf jre-8u73-linux-x64.tar.gz
Then you can set the java home by editing the environment file and set java home like :
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
where the latter part is the directory in which you have installed java.Usually java will be installed in the /usr/lib/ .Use an editor like nano or vim to edit the file and add the above key value to set java home.

Related

Installing JVM 8 on Mac with M1 chip

I'm trying to install GrObId and it requires JVM8. Will installing JDK work for this on an M1 Mac?
Install Azul's M1 native JDK 8.
You may obtain an installer for Java 8 (LTS) . The current version is Azul Zulu: 8.64.0.19 (8u345b01) in .dmg format.
Open the disk image and install.
Next you will need to set your JAVA_HOME environment variable.
Open the Terminal.app and run this command:
% open .profile ; open .cshrc ; open .zshrc; open .login; open .bash_profile
The file /Users/risner/.zshrc does not exist.
The file /Users/risner/.login does not exist.
Ignore any "does not exist" errors. You should have a couple of files open.
If you have any files called .cshrc or .login open, add this end of the file:
setenv JAVA_HOME /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
If you have any .zshrc, .profile or .bash_profile open then add this line instead:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Next, quit terminal and reopen. You should now be able to install GrObId.

Java home folder is different for sudo user on AWS

I have read many instructions on the problem, but I cannot get the sudo user (the normal ec2-user works fine) to use the proper JAVA_HOME folder.
I have tried:
set JAVA_HOME in .bash of /root and default user
set JAVA_HOME in etc/bashrc
set Default keep_env += JAVA_HOME in etc/sudoers
I use to set JAVA_HOME:
export JAVA_HOME="/usr/lib/jvm/jdk-11"
PATH=$JAVA_HOME/bin:$PATH
and I tried:
############set java home
export JAVA_HOME="/usr/lib/jvm/jdk-11"
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
restarted the instance after all these changes
still sudo java -version keeps pointing to the old java location (1.8 and i need 11)
what am I missing?
Regards,
Rick
After making changes to your .bash file, source it using command
source .bash
and try to check the version.

Error: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-oracle/jre/bin/java when i run gradle command in terminal

I am working in Ubuntu 16.04. I need to install gradle and the gradle is installed when i checked with sudo apt list --installed command but when i use gradle -version command it shows the following error,
JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-oracle/jre/bin/java
In sudo vim /etc/environment file,
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"
http_proxy="http://username:password#IP:port no/"
https_proxy="https://IP:port no/"
ftp_proxy="ftp://IP:port no/"
I don't know where i made mistakes. Please help me.
Thanks.
On a 64bit openSuse 64 42.1 box;
readlink -f $(which java)
provided;
/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/bin/java
But;
export JAVA_HOME=/usr/lib64/jvm/jre-1.8.0-openjdk
is the path that worked and allowed java emulator to run.
So i think we have to manually browse our file system and see what path to choose.
Today I faced this problem. I am using the default java that comes with your linux distro (so in my case, linux mint).
$ whereis java
This command gave me
java: /usr/bin/java /usr/share/java
So, I opened /user/bin. There was a link to Java. I right clicked it and selected follow original link. This lead me to /usr/lib/jvm/java-11-openjdk-amd64/bin/java.
So now that I know where this java is, I opened my .bashrc file, and edited the JAVA_HOME.
So for my case,
## My Custom variables
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
This solved the problem.
Now if you are using some other java (say you downloaded from oracle and extracted the zip file ...), then you have to add that location. So for example, if your java is in /home/user/.sdkman/candidates/java/current, then
export JAVA_HOME=/home/user/.sdkman/candidates/java/current
export PATH=$JAVA_HOME/bin:$PATH
I see a mismatch. In your enviornment file the JAVA_HOME is set to "/usr/lib/jvm/java-8-openjdk-amd64/" and your mentioned that the error that you got relates to the JAVA_HOME as "/usr/lib/jvm/java-8-oracle/jre/bin/java"
If you JAVA is really installed in /usr/lib/jvm/java-8-oracle directory, then you need to ensure that the JAVA_HOME is set to that directory. And also your PATH reflects $JAVA_HOME/bin in it.
I typically install Oracle JDK/JRE separately in a separate directory such as /usr/local/jdk1.8.0 etc.
check the jvm installtion folder from Files
eg : /usr/lib/jvm/java-12-oracle
then in terminal run sudo nano /etc/environment and add the line
JAVA_HOME="/usr/lib/jvm/java-12-oracle"
Then open terminal and run
export JAVA_HOME="/usr/lib/jvm/java-12-oracle"

Oracle SqlDeveloper JDK path

I have recently installed sqldeveloper but i'm getting the below warning window when I try to launch it. This is causing the sqldeveloper to run very very slow and it hangs frequently
I have tried editing the file sqldeveloper.cong as suggested in the window above but does not work
Original
SetJavaHome ../../jdk
Update 1
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\ and all other variations but still getting the above warning window
Update 2
SetJavaHome C:\Program Files (x86)\Java\jre7\bin and all other variations
Please suggest the correct way
The message seems to be out of date. In version 4 that setting exists in two files, and you need to change it in the other one, which is:
%APPDATA%\sqldeveloper\1.0.0.0.0\product.conf
Which you might need to expand to your actual APPDATA, which will be something like C:\Users\cprasad\AppData\Roaming. In that file you will see the SetJavaHome is currently going to be set to the path to your Java 1.8 location, so change that as you did in the sqldeveloper.conf:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\
If the settig is blank (in both files, I think) then it should prompt you to pick the JDK location when you launch it, if you prefer.
another thing you could try is to rename your old jdk folder, lets say its:
C:\Program Files\Java\jdk1.7.0_04
change it to saomething like:
C:\Program Files\Java\xxxjdk1.7.0_04
Now, you should once again asked to set your jdk folder location on Oracle SqlDeveloper launch, and you can chose the right path.
Not the most elegant solution, but it worked for me.
Milos
In your SQL Developer Bin Folder find
\sqldeveloper\bin\sqldeveloper.conf
It should be
SetJavaHome \path\to\jdk
You said it was ../../jdk originally so you could ultimatey do 1 of two things:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60
This is assuming that you have JDK 1.7.60 installed in that directory; you don't want to point it to the bin folder you want the whole JDK folder.
OR
The second thing you can do is find the jdk folder in the sqldeveloper folder for me its sqldeveloper\jdk and copy and paste the contents from C:\Program Files\Java\jdk1.7.0_60. You then have to revert your change to read
SetJavaHome ../../jdk
in your sqldeveloper.conf
If all else fails you can always redownload the sqldeveloper that already contains the jdk7 all zipped up and ready for you to run at will: Download SQL Developer The file I talk about is called Windows 64-bit - zip file includes the JDK 7
I cannot believe Oracle's documentation is SO LAME! In some documents it is misleading people to point to the JDK by specifying the path to the JDK root, e.g. on a Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/
Reviewing /Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
revealed the method they use to set up the path:
TMP_PATH=/usr/libexec/java_home -F -v 9
if [ -z "$TMP_PATH" ] ; then
TMP_PATH=/usr/libexec/java_home -F -v 1.8
if [ -z "$TMP_PATH" ] ; then
osascript -e 'tell app "System Events" to display dialog "SQL Developer requires a minimum of Java 8. \nJava 8 can be downloaded from:\n http://www.oracle.com/technetwork/java/javase/downloads/"'
exit 1
fi
fi
Executing this manually from Terminal:
/usr/libexec/java_home -F -v 1.8
Lists the path as:
/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
And this is what you need to specify as the value for
SetJavaHome /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Thank you Oracle for wasting half a day on your "product" that does NOT even support your latest Java version, also released by you.
On Windows,Close all the SQL Developer windows. Then You need to completely delete the SQL Developer and sqldeveloper folders located in user/AppData/Roaming. Finally, run the program, you will be prompted for new JDK.
Note that AppData is a hidden folder.
For those who use Mac, edit this file:
/Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
Mine had:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
and I changed it to 1.8 and it stopped complaining about java version.
if you use sqldeveloper 18.2.0
edit %APPDATA%\sqldeveloper\18.2.0\product.conf
jdk9, jdk10, and jdk11 are not supported
change back to jdk 8
for example
SetJavaHome C:\Program Files\ojdkbuild\java-1.8.0-openjdk-1.8.0.191-1

how to run jar file on RHEL5?

I have made a jar file which i tested in windows and it works fine. now i want to test it for red hat enterprise linux 5. but i dont know how to run jar files in rhel5.
i've tried java -jar My.jar but it says bash: java: command not found. i've set JAVA_HOME variable as export JAVA_HOME=/root/jdk1.6.0_21 but still not working.
can anybody tell me how to run jar file in rhel5?
You need to set PATH variable , something like
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
replace /usr/java/jdk1.5.0_07/bin with path to your jdk's bin directory.
The problem is your terminal tries to find java command from the PATH , but it couldn't find it.
Update:
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Top tip but slightly off topic.
1) Install your JDK in /usr/local/jdkX.X.X_XX/
2) Create a symbolic link /usr/local/java -> your chosen JDK installation
When you install new versions of java or if you want to revert to an older version, just change the symbolic link.

Categories

Resources