In fact, the Java native platform is Linux, but it can be run across the platform just. There are even native JDK in Linux, but these jdk are not complete, so it's best to configure a jdk1,7 for future Tomcat, Android, and so on. The following is an example of JDK1.7 configuration in Debian to explain how to configure the JDK in Linux.
Download and installation of JDK1.7
1, first, as in the Windows configuration JDK, open the official website of Java (click to open the link) agreed to the agreement, download the Linux version of the JDK, download the compressed version of the. tar.gz. Remember to agree to the agreement, otherwise never let download. I386 32-bit version of the download Linux X86,AMD64 version of the Linux x64, do not make the wrong, otherwise configured, can never run. The Windows configuration jdk can refer to the JDK download, installation, and Deployment tutorial (click on the Open link).
2, it is best to download this file to the Linux/tmp folder, so this folder Linux a reboot, the contents of the inside will not.
3, then open the root terminal, the file extracted to USR/LIB/JVM this directory
Enter the instructions first to enter the TMP folder
Cd/tmp
Re-enter the instructions to extract the file to the USR/LIB/JVM directory:
Tar zxvf./jdk-7-linux-i586.tar.gz-c/USR/LIB/JVM
Of course, you are in the graphical interface, you can, in the following figure, first input a tar zxvf, and then drag the jdk-7u75-linux-i586.gz into the-C/USR/LIB/JVM, so you can less input something.
4, press Enter is long after the decompression process. Until the command line appears again, the file is compressed.
5, press the upper right corner of the attachment-> file into the file Manager, or use CD instruction dir, you can see the decompression,/USR/LIB/JVM more than a jdk1.7.0_15, which proves that the compression has been good.
Second, the configuration of JDK1.7
1, in the root terminal input instructions:
Gedit ~/.BASHRC
The console appears with a bunch of warnings don't care about it. This thing can't be opened with a graphical interface. Because root permissions are required to change this file, the following configuration is written at the bottom of the environment variable file:
Export Java_home=/usr/lib/jvm/jdk1.7.0_75export Jre_home=${java_home}/jreexport classpath=.:${java_home}/lib:${ Jre_home}/libexport Path=${java_home}/bin: $PATH
2, Ctrl+s Save after the exit, and then at the root terminal input:
SOURCE ~/.BASHRC
Make it effective.
3, restart our Debian Linux, or simply enter reboot to reboot.
4, restart and then open the root terminal, a line to enter the following instructions, when prompted to select the default JDK, we chose the JDK1.7 we have just installed, is generally the last item, here is the input 2 after the return.
Update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_75/bin/java 300update-alternatives--install/ Usr/bin/javac Javac/usr/lib/jvm/jdk1.7.0_75/bin/javac 300update-alternatives--config java
5, and then restart our Linux. These two, you do not restart, there is really a problem, the author pro-Test.
6, re-enter java-version appear jdk1.7 version information, prove that our jdk1.7 has been installed successfully.
Java-version
Third, the Java programming under the Debian
After you've done the JDK1.7 under Debian, of course, write Hello world. "Program to Shuangshuang.
1, we still enter the/tmp folder to create a new Hello.java, using the graphical interface, is the upper-left corner of the application-> file-> the left of the file system->tmp, and then right-click-> Create a new document-> blank document, Name it Hello.java, as shown in the following illustration:
Use the terminal to enter the following instructions:
Cd/tmptouch Hello.java
2, with Debian with the Gedit editor to open this Hello.java, or use the instructions:
Gedit Hello.java
3, and then typing the following Java code, save exit, this is not the focus. Today's lead is Linux:
public class hello{public static void Main (String args[]) {System.out.println ("Hello");}
4. At this point, you need to change the permissions in the Hello.java property, give all read and write permissions, and then most crucially, allow the program to execute the file.
5, then, like the Windows command line can be, after the root terminal into the TMP directory, enter:
Javac Hello.java
Of course, input Hello.java, do not want to lose the filename, you can also like the following picture, drag the Hello.java in:
6, if the compile time appears "insufficient authority", that is just did not give Hello.java an option to allow the program to run.
7, after, in the/tmp directory will be a hello.class, enter the following instructions:
Java Hello
You can run it.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.