0

This question already has an answer here:

I have downloaded and installed JDK 9 with NetBeans. NetBeans runs fine and I build test application that also runs fine from IDE. But if I run java command in terminal I have error

'java' can not be found in the following package:
...

So, where is my java? Should I download JRE separately?

Command

sudo update-alternatives --config java

gives

update-alternatives: error: no alternatives for java

marked as duplicate by karel, Eric Carvalho, Ravan, George Udosen, David Foerster Dec 20 '17 at 12:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • How did you install JDK 9 and Netbeans? – David Foerster Dec 20 '17 at 12:24
0

Edit your .bashrc file by

gedit .bashrc

Add these line at the last of the file

JAVA_HOME=/usr/lib/jvm/jdk1.7.0 

(this path may change according to your system)

(this you copy as it is)

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

then logout and login

  • To make this a useful answer, you may consider adding the information why this is needed and how to achieve it. – pLumo Dec 12 '17 at 14:38
  • askubuntu.com/questions/175514/how-to-set-java-home-for-java go to the link and follow steps – aman5319 Dec 12 '17 at 14:47
  • I have updated my /etc/environment with line JAVA_HOME="usr/local/jdk1.8.0_151/" and executed command source /etc/environment But java command still not recognized – vico Dec 12 '17 at 15:31
  • @vico you entered an invalid path. It's a good idea not to edit /etc/environment at all. I suggest putting the assignment in your .profile. But don't forget the leading / – Zanna Dec 20 '17 at 13:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.