Want to do java development in linux?How the environment is set up,How the first helloworld was implemented,Dedicated immediately:

1 environment setup

1.1 java jdk installationjava jdk is a necessary environment for java compilation and running,So first you have to install this package,Methods as below:

1) Download the jdk archive,Note that the version is x86 or x64, and windows is still

linux, to figure it out,I downloaded jdk-7u13-linux-i586.tar.gz;

2) Decompress the compressed package,And put the decompressed directory under/usr/lib/jvm /, the command is as follows (?Indicates the directory where your compressed 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 and create a corresponding environment variable java_home in /usr/lib/jvm/jdk1.7.0_13:Append the following line to ~/.profile:

export java_home =/usr/lib/jvm/jdk1.7.0_13

Environment variables are only effective for the current user when appended to ~/.profile,If appended to/etc/profile, it is effective for all users,Readers can

Choose as appropriate.

Update configuration:

~ $:source ~/.profile

4) Add classpath, and set a corresponding environment variable to /usr/lib/jvm/jdk1.7.0_13/lib,as follows:Append the following line to ~/.profile:

export classpath=$java_home/lib

Can also be added in/etc/profile, explained as (3)

Update configuration:

~ $:source ~/.profile

5) Check the jdk version and confirm that the installation was successful:~ $:java -version

If successful,It is displayed 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 bull knife-the first helloworld

At this step,Although we installed the full jdk, we did not install any integrated development environment,It's like vc6 is not installed in windows

Same, but by manually building and compiling the source files,We can run helloworld once and see if the jdk is installed correctly.Start....

1) Edit the source file helloworld.java, as follows

public class helloworld
      public static void main (string [] args)
         system.out.println ("hello, world!");

2) compile the source file,The following:

~ $: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 while the java bytecode file is.class suffix, but not required for execution,Pay attention to this,After execution, the output is as follows:

hello, world!

3 Going graphical with ide-installing intellij ide

Nowadays, although eclipse is rampant, intellij is indeed a good lightweight IDE. Take him as an example.Instant noodles like small, fine things.

1) Download intellij ide

The community version downloaded in this example

2) Unzip ("?" indicates the directory where idea-12.1.6.tar.gz is located), and place it in the/opt directory (can also be other suitable directories)

~ $:Tar -zxvf?/ideaic-12.1.6.tar.gz

~ $:Sudo cp?/idea-ic-129.1359/opt /

3) Add /opt/idea-ic-129.1359/bin to the environment variable

Can be added in ~/.profile or/etc/profile, but the scope of application is different, This example modifies/etc/profile and adds the following:

export path=$path:/opt/idea-ic-129.1359/bin

Update configuration:

~ $:source/etc/profile

4) Run ide

Enter idea.sh directly in the terminal to start the intellij development environment

~ $:Idea.sh

ok, what to do,I think everyone knows,Simply learn how to use intellij,How to create a new project,add files,engineering

Setting of properties,Compile, debug, and general ide.

  • Previous Introduction to the method of Java connecting to SQL Server under Windows
  • Next In-depth analysis of the encapsulation characteristics of classes in C ++ programming