Run a simple Java program after deploying the JDK in a Linux environment

Source: Internet
Author: User

Objective

The previous article explained in detail how to install the virtual machine +linux system in a Windows environment and successfully deployed the JDK.

But after we deployed the JDK, we judged that the success of the deployment was based on whether the "java-version" command had the correct content to print, perhaps not too convincing. May be able to run a correct Java program, regardless of perceptual or rational point of view, there will be a better understanding.

So this article writes a very simple Java code and compiles it in a Linux environment to prove that the JDK is deployed correctly.

Code verifies that the JDK deployment is correct

1, Cascade set up two directories

First set up two directories at once:

The parent directory Java_progream means that this directory is all used for Java code, and hello represents a Java program directory, which is of course named according to personal preferences can be different.

2, write a simple Java program

Enter the Java_program/hello directory and use VI to create a. java file (vi can be modified when the file name exists, can be created when the file name does not exist):

Writing a very simple code is to print out the characters "Hello":

Note that the arrow means that the edited text must be Wq saved before it is created.

3. Compiling Hello.java

using javac Hello.java to compile our written Java code, If there is a problem with the writing, there will be a compilation error message out, if the write is not a problem, then compile successfully, after the successful compilation of the Directory is:

See the presence of Hello.class and Hello.java two files.

4, the implementation of Hello.class

Now that the Hello.class has been compiled successfully, the final thing is to execute the file, using java Hello :

Print out the string "Hello", successfully

Postscript

If the above steps are OK and the results are seen successfully, then it is well proven that we have successfully deployed the JDK1.7 in the Linux environment.

On the basis of successful deployment of JDK1.7, we will further play a variety of distributed components such as Memcache, Zookeeper, Hadoop, and more.

Run a simple Java program after deploying the JDK in a Linux environment

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.