Use NotePad to develop a hello World Program

Source: Internet
Author: User

-- Start

Today, when IDE (integrated development environment) is widely used, many programmers forget the original Java development method. This article will give you a brief review.

1. Compile the helloworld class

In Start, Run, enter notepad to open notepad, enter the following content, save it under c: \ applications, and name it helloworld. Java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("HelloWorld");
    }
}
2. Compile and run helloworld

In start and run, Enter cmd to open the DOS command window and run the following commands in sequence:

1. Compile helloworld with a suffix. Why do we need to compile this step? Java is a cross-platform language. How does one implement cross-platform? Java introduces the concept of virtual machines to translate our programs into machine codes suitable for the target platform. We can see that the implementation of virtual machines on different platforms is different.

cd C:\Applications
javac HelloWorld.java
or javac C:\Applications\HelloWorld.java

2. Set the classpath environment variable. Why do we need to set the classpath environment variable? When we run Java helloworld, the Java command searches for helloworld in the path specified by classpath. class file, otherwise the virtual machine will tell us that the class cannot be found. maybe you think we are in helloworld. you can execute Java helloworld in the directory where the class is located,... (You know ).


set CLASSPATH=%%CLASSPATH%%;C:\Applications

3. Start the Java Virtual Machine to run helloworld. Note that there is no suffix.

java HelloWorld


4. You can specify the-classpath option instead of setting the classpath environment variable.


java -classpath C:\Applications HelloWorld


---For more information, see:Java
--Shengming: reprinted, please indicate the source
-- Last updated on 2012-05-17
-- Written by shangbo on 2012-04-20
-- End


Related Article

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.