Eclipse usage steps, differences between Javac and Java directives

Source: Internet
Author: User

Javac directives and Java directives:

Javac is responsible for compiling the source file into a bytecode file (. Class), which must be specified at compile time. Java suffix, cannot be omitted

The Java instruction is responsible for converting the bytecode file to machine code, running it, and omitting the bytecode file after the Java instruction. class suffix

The disadvantage of direct operation Javac compiling the source file: Every modification to the source file needs to be compiled again to run the result after the change

Solution: Use integrated development tools

Eclipse: Free, IBM offers, high penetration

myeclipse: Charges, functions as basic as eclipse, but more integrated

Eclipse usage Steps:

(1) Ensure that the JDK has been followed, the Java environment variable is configured correctly

(2) Unzip the eclipse package (green software, no install)

(3) Edit the Eclipse.ini under the Eclipse root directory

Append a line-dfile.encoding=utf-8 at the end, set the default encoding to UTF-8 encoding to avoid subsequent garbled problems

(means of avoiding garbled characters: Unified coding)

Eclipse Window Description:

Top: Feature menu bar, frequently used: file (Files), search (Find), window (Windows)
   
Left: Project file directory, showing a list of all projects, and the file structure within the project

Middle Area: Main editing area (mainly for code writing here)

right: outline, which is used to view the internal structure of a class file

bottom: Commonly used to view console output information, file compilation error messages, warning messages

List of items on the left in addition to the Project Explorer mode view, you can also choose to use the Package Explorer mode

Create a new Java project in Eclipse

a project can contain many Java files

file ==> New ==> Java Project

Define project name (English/pinyin)

project directory structure:

src: Store Java source code (must be created in SRC directory lower layer When creating Java file)

Bin: Storing the bytecode file (. Class) generated by the compilation

the concept of package in Java:

(1) package is used to group the class file management, similar to the folder in the computer file system

(2) class names under the same package cannot be duplicated, and class names under different packages can be duplicated

(3) under the package can be re-built package, can be composed of multi-layered package, multi-layer package name separated by "."

(4) The package name is generally used in plain lowercase letters

(5) Different levels of packages that can be used to control access to methods and properties in a class


Create a class file (. java source file) in Eclipse

Select the location where you want to create the class file (under one of the layers in src)

The new ==> class ==> defines the class name

If you need to add the main method automatically, you can tick the check box for public static void main (string[] arg when you create the class

To modify the editing area font size:

window ==> Preference ==> General ==> appearance ==> color and fonts ==> basic ==> text font

shortcut keys:

(1) Alt + "/": Code hint, auto complement

(2) Ctrl + Shift + F automatic layout, indentation, the level of the code to reflect

the Java code written by eclipse automatically compiles when you edit/modify the source code and save it

after each code change, remember Ctrl + S save, trigger automatic compilation, generate the latest. class file

(3) Ctrl + Shift +/: Quick Comment Selection

(4) Ctrl + Shift + \: Quickly remove comments from the selection

Eclipse usage steps, differences between Javac and Java directives

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.