I want to upgrade my Linux JDK from Oracle to Azul-Zulu.can someone helps me to do this.
What to do after downloading the tar.gz Zulu package?
I see that after extracting the downloaded package we need to put it in the path where we need to access java. Is that correct or what we can do more like setting environment variables etc.
the answer to your question depends on what you actually want to start with the JDK. Sometimes is is sufficient to change the path to java binary in a start script, e.g. Eclipse or Tomcat, sometimes you also need to setup the variable JAVA_HOME.
To setup the java for yourself only:
Check your shell by running echo $SHELL
-> /bin/bash
-> /bin/zsh
-> /bin/tcsh
or something like that Locate your shell's config file:
bash: ~/.bashrc
zsh: ~/.zshrc
tcsh: ~/.cshrc or ~/.tcshrc
and optionally most of the shells: ~/.profile or ~/.login check those file(s) if you already have variable declarations for: JAVA_HOME JRE_HOME (and rarely seen) SDK_HOME JDK_HOME
check whether any of those files contain a setup for the variable PATH (probably has)
If you found any of the *_HOME variables from above you can change them to reflect your new java home directory: e.g. zulu11.37.17-ca-jdk11.0.6-linux_x64 located under /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64 would mean to set the variables as follows: zsh and bash:
export JAVA_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
export JRE_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
tcsh
setenv JAVA_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
setenv JRE_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
SDK_HOME and JDK_HOME may point to the above locations as well but are normally unused.
If you located your PATH somewhere it may read something like this: zsh and bash:
export PATH=~/bin:$PATH
tcsh:
setenv PATH ~/bin:$PATH
In order for your new java to appear "before" the "other" java you need to update (or create if missing) this to e.g.: zsh and bash:
export PATH=~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
tcsh:
setenv PATH ~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
After completely logging out and in again your JAVA_HOME and PATH can be controlled in a shell like this:
echo $JAVA_HOME -> should point to *your* java folder
echo $PATH -> should contain *your* java folder's bin directroy
which java -> should list the new java binary instead of /bin/java or /usr/bin/java
BTW: the variables JAVA_HOME, JRE_HOME and PATH may also be set in a startscript, e.g. catalina.sh for tomcat or the eclipse.ini for eclipse if you do not want to modify your environment.
If you download the RPM/DEB instead of the tar.gz and install the package you (may) not need configure anything since the packages might re-configure your system for you
Cheers, Holger
Related
According to ORACLE's doc Quick Start for Platform Developers I used Jrecreate and got JRE .
I copied JRE to my Arm Linux, cd ./bin and inputted java -version.
But terminal displayed:-sh:java:not found
Do I miss any Share Library?
If you want an executable from your current directory to be callable by name you need . to be included in your $PATH, which isn't the case by default due to security concerns. Otherwise you have to provide an absolute or relative path to the executable such as ./java.
Another solution, which is the most common for java and other language development tools / runtime environments, would be to include the absolute path to your Java install's bin directory in the $PATH so that you can run java from anywhere. This is often done by first setting a $JAVA_HOME environment variable, then including $JAVA_HOME/bin in your path :
export JAVA_HOME="/usr/bin/java/" # or whatever your install path is
export PATH="$JAVA_HOME/bin:$PATH"
Either enter the location where your java executable actually is or add the java binary to your PATH environment variable.
If you read Oracles documentation, you need to do this after having run Jrecreate. (Please adapt destDir)
Recursively copy destDir from the host to the device directory where you want the JRE installed. For example:
$ scp -r /tmp/SmallJRE/* root#target:/opt/local/ejdk<version>/
If necessary, update the device's PATH environment variable to include the bin/ directory of the JRE. For instance:
$ PATH=$PATH:/opt/local/ejdk<version>/bin/
$ export PATH
Need some lib.and i used uclibc that don't support JRE.
I've downloaded java jdk1.8.0.7.tar.gz file from the official website and unzipped it into my home directory. Now to set the $JAVA_HOME variable I used the follwing commands command nano .bashrc and then appending export $JAVA_HOME=/home/shivam/Java/jdk1.8.0.7 at the end of the file . But whenever I run the command sudo $CATALINA_HOME/bin/startup.sh I get an error message saying
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
I don't understand why it is unable to find the java path though I've installed tomcat and set its home variable the this way, which worked.
I wan't to install Java manually without using apt-get. Kindly guide .
You want to append the following to .bashrc:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7
Note the missing $ at the start.
Also remember that the file won't effect your current shell without sourceing it first.
Also, when running a command with sudo, you are running it as the root user, not as yourself. So the environment variable needs to be set for the root user, not yourself.
You can run sudo env | grep JAVA_HOME to see whether it is set for root.
Have you run .bashrc ?
source .bashrc
Try add the following 2 lines in your .bashrc file:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7/
export JAVA_HOME
I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.
I created a helloworld.java application and am able to compile it using:
javac helloworld.java
However, when I try to run:
java helloworld
I get the error:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
How can I solve this?
1.Just go to C:\ProgramData\Oracle\Java\javapath\
2.You will find there shortcuts for java.exe,javaw.exe,javaws.exe which are pointing to a location where they actually are not existing now
3.Go to the jre location where you have installed java like C:\Program Files\Java\jre6\bin
You will find java.exe,javaw.exe,javaws.exe
Create shortcuts for these files and replace with the ones which are present in C:\ProgramData\Oracle\Java\javapath.
It works
Just set %JAVA_HOME%/bin to your path variable.
If you are blocked from modifying system variables from command line, but are able to open up an elevated command prompt, then run a command like this:
setx \M JAVA_HOME "C:\Program Files\Java\jdk1.8.0_25"
But of course, change the directory to point to your installed version of java. Note that the JAVA_HOME path does not point into the bin directory, it stops one level above bin.
I was able to solve this issue. To do so I used the advice from this answer:
Java SE Development Kit 8u25 on a 64-bit Windows 8
Set the following user environment variables (== environment variables of type user variables)
•JAVA_HOME : C:\Program Files\Java\jdk1.8.0_25
•JDK_HOME : %JAVA_HOME%
•JRE_HOME : %JAVA_HOME%\jre
•CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
•PATH : your-unique-entries;%JAVA_HOME%\bin
(make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.)
I am using jdk 1.7, after Installation I did not set JAVA_HOME or CLASSPATH environment variable, and I use it to compile a servlet class and everything worked fine.
So I want to known, why I am not supposed to set these Environment variables ? Can JDK auto resolve CLASSPATH ?
JAVA_HOME is used by some tools (Ant, Maven, etc.), but is not needed by Java (or javac) itself.
CLASSPATH should never be used. It sets a global classpath that is supposed to be common to several Java programs installed on your computer, which is completely unrealistic. Every program should have its own classpath passed as argument to the command using the -classpath option.
And that's true on all the platforms.
Most of the Unixes and Mac use the so-called Bash Shell in the "Terminal". When you launch an executable program (with file permission of executable) in a Bash shell, the system searches the program in ALL the directories listed in the PATH.
The have JAVA_HOME path and can be set as:
setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Home
To setup JAVA_HOME:
$ vi ~/.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source ~/.bash_profile
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
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.