I am beginning to code in java, downloaded the binary from here. Then followed the instructions from here, however I was met with some errors regarding java-package and I ran into this which solved my problem and I went ahead with following the instructions on that page and installed the binary package created.
$ javac -version
javac 10.0.2
$ java -version
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
$ javac Hello.java
compiles the program successfully
Unable to run the program,
$ java Hello
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
The instructions I found online are not clear. Most of them use OpenJDK, and I know I could've gone with that but since I'm already into Oracle's I'm wanting to go with that.
So there's manual installation in which I've seen people creating their own directory and moving the extract of the binary package there and then running some update-alternative
commands to apparently set it up.
But I've followed Debian's wiki and used java-package.
I'm actually quite confused. Can someone clearly explain all this? Would be really appreciated.
I did
$ sudo gedit /etc/profile
and added these two lines at the end-
export JAVA_HOME=/usr/lib/jvm/oracle-java10-jdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
and now,
$ java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
It looks like
javac
compiler is in yourPATH
, butjava
virtual machine is not - strange.As I can see you have created deb package named like
oracle-java10-jdk
or something and installed it. Use$ dpkg -L oracle-java10-jdk | grep -E /java$
to see where
java
command is and add it to yourPATH
.