Configuration command:
$sdo apt-get install ubuntu-restricted-extras
Run the following command again:
$sudo apt- get install sun-java6-jdk
After the installation is complete, select the default Java.
$sudo update-alternatives --config java
When prompted during the installation process, enter "2 ” and then press the Enter key to confirm.
If everything goes well, you can start configuring environment variables and run the following command in the terminal:
$sudo gedit /etc/environmet
Add the following two lines:
CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib
JAVA_HOME=/usr/lib/jvm/java-6-sun
After saving and exiting, run the following command:
$sudo gedit /etc/jvm
Fill in the line "/usr/lib/jvm/java-6-sun" in the file to Configure the top of the block.
After installing and configuring Eclipse, run the following installation command in the terminal:
$sudo apt-get install eclipse
So far, Eclipse has been installed on the Ubuntu system.
Use the Ubuntu main menu "Applications" - "Programming" - "Eclipse" option to start Eclipse. After starting, Eclipse will first ask for the working folder. Unless there are special requirements, just click the "OK" button to continue, and the Eclipse welcome interface will appear later.
Special Tip: Configure the Java environment of the university. Although the newly installed Java has become the default JVM of the system, Eclipse will not start using the JVM set by update-alternative just now, but will use the one with low performance. GNU Java. Since GNU Java is an implementation of Java 1.4.2, it is far inferior to Sun's implementation in terms of performance. Therefore, in order to allow Eclipse to start using Sun Java, it needs to be configured. The specific configuration method is as follows:
First, install Sun Java Completely set as the system's default JDK:
$sudo vim /etc/jvm
Change the line "/usr/lib/jvm/java-6-sun" in the file Fill in the top of the configuration block. Since Eclipse will ignore Ubuntu's general Java environment setup settings, you still need to continue editing Eclipse's java_home file:
$sudo vim /etc/eclipse/java_home
As above, change "/ Add the line "usr/lib/jvm/java-6-sun" to the top of the file.
The above is the detailed content of How to set up a Java environment in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!