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”
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
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"); } }
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!