I have a Ubuntu machine where I already have one JDK version which is installed.
Next I have downloaded the second version into /usr/local
.
Now, I want to run a program against the second JDK which is in /usr/local
, i.e., I will copy a sample .java
program in /usr/local/bin
and then execute it.
But the problem is, even If I navigate to the /usr/local/bin
and type $ java -version
, I am getting the one which is installed in the first place. Is there any solution for this?
type sudo update-alternatives --config java
The select the version you want.
And I think this question should be moved to askubuntu.
When you run java
with no path, then your shell looks in your $PATH
environment variable to find java
.
If you want a specific java
, you need to either change your $PATH
, or run it with a path, like:
/usr/local/bin/java
or if you really want to cd
there first, you could run
./java
from /usr/local/bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With