Linux under the Java Development environment and the first Helloworld_java

Source: Internet
Author: User

Want to do Java development in Linux? How to build the environment, the first HelloWorld how to achieve, the following immediately dedicated:
1 Environment Construction
installation of 1.1 Java JDK
Java JDK is a necessary environment for Java compilation and operation, so you must first install this package as follows:
1) Download the JDK compression pack,Note the optimistic version is x86 or x64,windows or
Linux, to find out, I am under the jdk-7u13-linux-i586.tar.gz;
2 Extract the compressed package, and put the extracted directory below the/usr/lib/jvm/, command as follows (?) Indicates the directory where your zip package is located):
~$:TAR-ZXVF?/jdk-7u13-linux-i586.tar.gz
~$:sudo MKDIR/USR/LIB/JVM
~$:sudo CP?/JDK1.7.0_13/USR/LIB/JVM
3) Add Java_home,/usr/lib/jvm/jdk1.7.0_13 to establish a corresponding environment variable java_home:
Append the following line to the ~/.profile:
Export java_home=/usr/lib/jvm/jdk1.7.0_13
In ~/.profile Append, the environment variable is valid only for the current user, and if appended in/etc/profile, it is valid for all users, and the reader can
Choose as appropriate.
Update configuration:
~$:source ~/.profile
4) Add Classpath, the/usr/lib/jvm/jdk1.7.0_13/lib to create a corresponding environment variable, as follows:
Append the following line to the ~/.profile:
Export Classpath= $JAVA _home/lib
can also be added in/etc/profile, as explained (3)
Update configuration:
~$:source ~/.profile
5 View JDK version to confirm installation success:
~$:java-version
If successful, the display is as follows:
Java Version "1.7.0_13"
Java (TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot (TM) Server VM (build 23.7-b01, Mixed mode)

2 small test--the first HelloWorld
At this point, we installed the full JDK, but did not install any integrated development environment, just like Windows did not install VC6
, but by manually building and compiling the source files, we can run the HelloWorld first, see if the JDK is installed correctly, and start ....
1 Edit source file Helloworld.java, the contents are as follows

 public class HelloWorld 
    {public
      static void Main (string[] args)
      {
         System.out.println ("hello,world!"); return
         ;
       }
    

2) Compile the source file as follows:
~$:javac Helloworld.java
The Helloworld.class file is generated after compilation, which is the so-called Java bytecode generated after compilation.
3 Execute Java bytecode , as follows:
~$:java HelloWorld
Note that although the Java bytecode file is a. class suffix, it is not required for execution, and this should be noted that, after execution, the output is as follows:
hello,world!

3 using the IDE to move towards graphics--installing the IntelliJ IDE
Now, although eclipse is rampant, but IntelliJ really a good lightweight IDE, take him as an example, bubble noodles like small and fine things.
1) Download IntelliJ IDE
http://www.jetbrains.com/idea/download/
In this case, the Community version is downloaded
2 decompression ('? ') Represents the ideaic-12.1.6.tar.gz directory) and is placed under the/OPT directory (or other appropriate directory)
~$:TAR-ZXVF?/ideaic-12.1.6.tar.gz
~$:sudo CP?/idea-ic-129.1359/opt/
3 Add/opt/idea-ic-129.1359/bin to environment variables
Can be added in ~/.profile or/etc/profile, just the scope of application of different, this example to modify the/etc/profile, append the following:
Export path= $PATH:/opt/idea-ic-129.1359/bin
Update configuration:
~$:source/etc/profile
4) Running the IDE
Start IntelliJ development environment directly in terminal input idea.sh
~$:idea.sh
OK, what's left to do, I think we all know, a simple study of the use of IntelliJ, such as how to create new projects, add documents, engineering
property settings, compilation, debugging, the General IDE is the case.

The above is to share with you about Linux under the Java Development environment and the first HelloWorld, hope can really help everyone.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.