简体   繁体   中英

Set Java environment variable problem on ubuntu

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!

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

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.

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"

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM