Home > Java > javaTutorial > body text

How to set up a Java environment in Ubuntu

WBOY
Release: 2023-05-03 09:28:06
forward
1721 people have browsed it

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!