Getting started with Java compiler

Source: Internet
Author: User

Main content of this article

I used to have such a short period of time. I was very interested. I wanted to see Java and understand it. However, every time the duration was not long, I forgot something after a while. After several such experiences, I decided to take another time to take a good look and write this blog post to record this process.

 

Brief content

1. How to Build a Java Development Environment?
2 compiler javac usage
3. Run the Java compilation result File

 

Before 0 -- download and install JDK

The download and installation process is simple. Note:

(1) folder docs: Decompress the downloaded document package.

(2) folder tutorial: Guide, which also needs to be downloaded separately

If you want to get two folders, You Need To separately download the related compressed packages.

 

1How to BuildJavaDevelopment Environment

To make Java easier and easier to use, set environment variables. I have referenced several articles on the Internet, but because I do not like to set system variables or user variables, I am used to creating a Java development environment suitable for my use by defining methods in batch processing and shortcuts.

 

Step 1: compile a batch file with the following content:

//////////////////////////////////////// /Java-path.bat ////////////////////////////////////// ////////

@ Echo off

Rem sets Java environment variables to facilitate Java programming

Set JAVA_HOME = C: \ Program Files \ Java \ jdk1.6.0 _ 21

Set Path = % java_home % \ bin; % java_home % \ .. \ jre6 \ bin; % PATH %

Set classpath =.; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ tools. Jar

Echo on

/// // This file is complete

For environment variable settings, refer:
Http://wenku.baidu.com/view/80732575a417866fb84a8e5b.html

 

Step 2: complete. Click here to find the cmd.exe program under the system folder of winrar%, pointing to it to create our shortcut. (On my computer, % comspec % = c: \ windows \ system32 \ cmd.exe.

 

Step 3: After the shortcut is created, some modifications are required to meet the requirements. Right-click the shortcut and select Properties to modify the content on the shortcut tab.

Edit box at destination (T) with content changed to: % comspec %/K java-path.bat"

(Recommended java-path.bat with a circle path, so that the shortcut stored in which location is not important)

(You can use double quotation marks to enclose the full path to prevent the folder from containing spaces. The specific setting parameters in the figure are:% Comspec %/k "F: \ OpenProj \ 08_JavaOpenProj \ java-path.bat "")

Start position: Set it to a common folder. Double-click the shortcut and it will stay in the folder.

See

Double-click the shortcut to open a Java compiling environment at any time.

 

2CompilerJavacGetting started

Here the content of the specific reference URL (http://www.programbbs.com/doc/477.htm), focus on how to compile multiple files at a time.

File List
To shorten or simplify the javac command, you can specify one or more files with one file name in each line. In the command line, use the '@' character plus the file name to specify it as the file list. When javac encounters a parameter starting with '@', it performs the same operations on the file name contained in the file as on the file name in the command line. In this way, the Windows naming line length is no longer limited.

 

Compile multiple source files
This example compiles all source files in the greetings package.
C:> javac greetings \ *. Java

 

3RunJavaCompile result File

Run Java commands. Example: java Welcome

If multiple files work together, execute the file that includes the main function.

However, if the package is used in the java source file, it is a bit confusing. For this problem, you can refer to the web site (http://www.weaseek.com/20070124/142643938.htm), detailed explanation of the java source file involved in the package problem, speak very well, clarified my questions, now I will execute the file compiled in this way.

Other content is skipped first. I rarely use Java for development. Many things are still unclear, and I don't know what to say or what to say, so I don't want to be ugly anymore.

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.