tags:

views:

2216

answers:

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!

+2  A: 

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
BobiYo
But I already install sun-java6. any idea with java 6?
Sinal
+2  A: 

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 usinging 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.

Steen
A: 

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"
D. Wroblewski
+3  A: 

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

Jesper
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.
shmuelp