Home > Java > javaTutorial > body text

How to build a Java development environment using ubuntu

王林
Release: 2023-04-18 11:46:02
forward
1039 people have browsed it

1. jdk installation
Okay, I chose jdk1.6, is it a bit out?
1. To download jdk1.6, you can go to the official website to download. Please check your system version clearly when downloading, and remember to download the corresponding version.
2. Place the downloaded file in the /usr/lib/java directory (the java directory needs to be created manually), and modify the executable permissions of the file, such as chmod 777 jdk-6u41-linux-x64.bin
[ps: If it prompts that the file java already exists and java cannot be created, you can name the directory java1.6 (indicating that this is jdk 1.6 version)]
3. Installation file, sudo ./jdk-6u41 -linux-x64.bin
4. After the installation is completed, you need to configure the system environment sudo vi /etc/environment, or configure the user environment variable vi /home/username/ .bashrc, create javahome, classpath, modify the path variable
For example, my setting is:

java_home=”/usr/lib/java1.6/jdk1.6.0_41″
path=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/java1.6/jdk1.6.0_41/bin:/usr/lib/java1.6/jdk1.6.0_41/jre/bin”
classpath=”/usr/lib/java1.6/jdk1.6.0_41/lib:/usr/lib/java1.6/jdk1.6.0_41/jre/lib”
Copy after login

5. Execute the command to make the configuration take effect. source /etc/environment ( source /home/username/.bashrc )
6. Verify whether the installation is complete. Use java -version or javac directly to see whether it takes effect.
7. If it has not taken effect yet, it is very likely that there is a default jdk in ubuntu, such as openjdk. Therefore, in order to use the jdk we installed by default, the following work must be done.

sudo update-alternatives –install /usr/bin/java java /usr/lib/java/jdk1.6.0_41/bin/java 300
sudo update-alternatives –install /usr/bin/javac javac /usr/lib/java/jdk1.6.0_41/bin/javac 300
Copy after login

Through this step, we will add the jdk we installed to the java menu.
Then execute:
update-alternatives –config java
2. Myeclipse installation
Download the installation package. After the download is completed, modify the permissions and execute directly Installable.
3. The first hello world program

1) Create a new java project and name it helloworld
2) Create a new package and name it com.cricode
3) Create a new class sayhello in the package com.cricode with the following content:

package com.cricode;
 
public class sayhello {
 public static void main(string[] args){
 system.out.println("hello,world");
 }
}
Copy after login

Running results: hello,world

The above is the detailed content of How to build a Java development environment using 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!