Javac and Java commands execute Java programs

Source: Internet
Author: User

Javac [Options] [SourceFiles] [@files]: Compile a Java file.

1. Note that the execute command must be specified to the path containing the Java file, or the file error cannot be found.

2. If the JVM is not installed, the JAVAC command will not be recognized.

Simple example of a program:

A source file Hello.java, which defines a name greetings. Hello's class. The Greetings directory is the package directory for both the source and class files, and it is not the current directory. This allows us to use the default User class path. It also makes it unnecessary for us to use-The D option specifies a separate destination directory. C:>dirgreetings/C:>dir greetingshello.javac:>Cat Greetings\hello.java PackageGreetings; Public classHello { Public Static voidMain (string[] args) { for(inti=0; i < args.length; i++) {System.out.println ("Hello" +args[i]);}}} C:>javac Greetings\hello.javac:>dir Greetingshello.classHello.javac:>Java Greetings. Hello World Universe Everyonehello worldhello Universehello Everyone

Javac and Java commands execute Java programs

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.