"Java Learning" Javac and Java commands

Source: Internet
Author: User

For Java classes that are not in the package

For example Mywindow.java under the C:\Users\guoyan\Desktop directory

① first cut to the current directory

C:

CD C:\Users\guoyan\Desktop

② performing Javac Mywindow.java compilation

③ execute Java Mywindow run again

For Java classes in packages

Example: Hello.java in the C:\Users\guoyan\Desktop\Test directory, in the test package

① first cut to the current directory

C:

CD C:\Users\guoyan\Desktop\Test

② performing Javac Mywindow.java compilation

Compile and cut to upper-level directory (C:\Users\guoyan\Desktop\)

Cd..

③ execute Java Test.mywindow run again

You can also compile the Hello.java in the C:\Users\guoyan\Desktop\Test directory into a different folder

For example, compile to C:\Users\guoyan\Desktop\myclass (compile generated. class file in this directory)

① first cut to the current directory

C:

CD C:\Users\guoyan\Desktop\Test

② performing javac-d C:\Users\guoyan\Desktop\myclass Hello.java compilation

Compile and cut to C:\Users\guoyan\Desktop\myclass

CD C:\Users\guoyan\Desktop\myclass

③ Run

Java Test.hello

Jar Packaging Related commands

Typically, you need to package a compiled. class file to generate an executable file

① Write a configuration file

Arbitrarily name A. txt file, such as Config.txt

File contents:

Main-class:test.hello

(Note that there will be a space after the colon, and finally a newline to indicate the end of the file content)

② Cut to Directory (C:\Users\guoyan\Desktop\myclass)

Execute JAR-CVFM my.jar config.txt Test Package

Perform Java-jar My.jar operation

or double-click to run (double-click the case without the console, can only represent the graphical interface)

"Java Learning" Javac and Java commands

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.