Use Notepad to write and run a Java program

Source: Internet
Author: User

A. Download jdk


can be downloaded at Oracle website:

Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Note Select 36-bit or 64-bit

After downloading follow the steps to install it gradually

note, however, that the JDK and JRE cannot be installed in the same directory, otherwise the Javac command cannot be found at run time

This is because the JRE only provides a Java program's operating environment, after the JDK installed, if the JRE installed in the same directory, the JRE will automatically delete some unrelated files, will be the JDK complete javac command to erase



Two. Configure environment variables (with JDK installed in G:\JAVA\JDK for example)


Java_home:g:\java\jdk

Path:%java_home%\bin;%java_home%\jrd\bin;

Classpath:.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;

Note the quotation marks to be added in English when appending in path paths;



(Open cmd to check if the installation was successful)

Input Java-version,javac,java

can be executed correctly and the installation is successful



3. Create a new text document (take Hello.java as an example)


Use Notepad to open, and then write a Java program, where the class name to be consistent with the filename, the suffix must be modified to. java


public class hello{public
   static void Main (String arg[]) {
      System.out.println ("Hello world!");
}



4. Open cmd, enter the directory of your Java files (here on the desktop)


Input: Javac Hello.java for compilation

Then you can see that the Java file you wrote with the Hello.class in the same directory shows the success of compiling


Re-enter Java Hello execution

Correct output in cmd


Reprint Source: http://blog.csdn.net/bazingaea/article/details/51811542

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.