4

I got a message "No Java virtual machine could be found from your PATH environment variable. You must install a VM prior to running this program." Does anyone know how set up it correctly? Thanks!

4 Answers 4

7

If you install Java the Ubuntu way, you won't have to add it to the PATH yourself.

First, install Java from the Ubuntu repository:

sudo apt-get install sun-java6-jre

There are several other packages: sun-java6-jdk for the JDK, sun-java6-plugin for the browser plug-in etc.

Use Ubuntu's alternatives mechanism to select Sun Java 6 as the default version of Java that you want to use:

sudo update-alternatives --config java

This will present you with a menu where you can choose which version of Java you want to use by default (you can have multiple Java versions installed at the same time on your system).

See: https://help.ubuntu.com/community/Java

Sign up to request clarification or add additional context in comments.

2 Comments

Note that all the other command-line programs installed with Java and controlled separately and may need to be updated as well. As per the link, you can do that with the update-java-alternatives command.
this answer doesnt work on suse or redhat, by the way, when you install from jdk rpms downloaded from oracle.
5

As the error message says, this looks like you have not set your PATH or JAVA_HOME environment variable correctly.

can you execute java from the command line? Try:

$ java -version

or

$ dpkg -L sun-java6-jre

Provided your are using debian or some derivative of it, if the "dpkg ..." command gives you any useful output, you should set the JAVA_HOME to the location of the installation directory, for instance

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10
export PATH=$PATH:$JAVA_HOME

and you should be able to get java running.

Comments

3

First make sure you have the path to your java binaries.

locate javac

This will return a list of all locations matching "java". Look for something like "/usr/lib/jvm/java-6-sun-1.6.0.11".

Open /etc/environment with a text editor and add the following. Make sure you set JAVA_HOME to the actual path of the java installation directory you just found:

export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.11"
export PATH="$PATH:$JAVA_HOME/bin"

Comments

2

I think that you need to install this package

sudo apt-get install sun-java5-bin

also check this

> #!/bin/bash
> # Init Script for j2re
> #This goes in /etc/profile.d
> 
> JAVA_HOME=/usr/java/j2reVERSion
> PATH=$JAVA_HOME/bin:$PATH
> 
> export JAVA_HOME PATH

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.