How to execute a Java program using the doscommand line

Source: Internet
Author: User

I started to learn Java today. I borrowed a book from the library from deitel. I am stuck with the above or using the command line to run Java.ProgramThere is no ide, as some beginners may need to do so, write the method. Install JDK first, and remember the installation path. Next, we need to set the environment variable. The path environment variable defines the search directory for the application.

Right-click computer> Properties> advanced system Settings> advanced> environment variables> system variables, find path, and edit

After editing, add the path D: \ tddownload \ eclipse3.5 \ jdk1.6.0 _ 16 \ bin; (this is my path) to the beginning of the environment variable. OK.

Next, open dos, win + R, and Enter cmd. Use the CD command to switch to the directory where you want to create a Java file. Then create a simple Java file.

It can be written in any text editor and saved as a. Java file after being written.

For example, creating a file welcome1.java

Public ClassWelcome1 {Public Static VoidMain (string ARGs []) {system. Out. println ("Hello, world");}}

Then, compile the javac welcome1.java command.

After compilation, you can run Java welcome1 to view the execution result.

 

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.