Java Experiment One

Source: Internet
Author: User

Course: Mobile Platform Application development Practice class: 9217

Name: Cai Binsi No.: 20159217

Score: Instructor: Lou Jia Peng Experimental Date: 2015.10.04

Experiment level: Preview degree: Experiment time:

Instrument Group: Compulsory/Elective: Elective experiment number: 1

Lab name: Familiarity with the Java development environment

Experimental purposes and requirements:

1. Compiling and running a simple Java program using the JDK

2. Edit, compile, run, and debug Java programs using Eclipse

Experimental instrument:

Name

Model

Number

Pc

1

Virtual machines

Laboratory Building

1

First, the contents of the experiment:

1, the command line under the Java program development

2. Java program development and debugging under Eclipse

3. Practice

Second, the experimental process:

(i) Java program Development under command line

1. Open the terminal

2. Enter the CD Code command to enter code

3. Enter the mkdir 20135100 command to set up the experiment directory, note that the directory name is its own school number, this place was mistaken, and then modified a bit

4. Enter the CD 20135100 command into the experimental directory, and then enter a similar mkdir EXP1 to establish the first experimental directory, and then enter the CD EXP1 into the experimental directory, you can enter PWD to view the current command path

5. Enter Gedit Hello.java (note Save the code in the EXP1 directory)

6. Enter javac-d. Hello.java command to compile the code, enter the Java LJP. The Hello command runs the program.

(ii) Development and commissioning of Java programs under Eclipse

1. Enter eclipse in the terminal window and enter the Eclipse interface;

2. Open "File--new--java project", and in the popup dialog box, in Project name, fill in the Hellojdk and click "Finish";

3. Open "File--new--class" in turn, in the popup dialog box, enter the package name in the Packag column: JWM, in the Name field, fill in the class name HELLOJDK, note the tick

3. Enter the code according to the title:

4. Click the Run button (or use the CTRL+F11 shortcut key) to see the results of the run in the console.

5. Practice the debugger, first we open the Debug view by clicking Window->open perspective->debug.

6. The debugger first sets breakpoints and one- step operation . You can see the program stays on line seventh after you click Debug.

7. Step execution efficiency is slow, if we feel that the 7th line to the 11th line of code is no problem, want to let the program run directly to line 12th, what to do? First we'll set the breakpoint on line 12th and then click the Resume icon (shortcut F8).

8. One-Step execution efficiency is slow also leads to another problem, such as a cycle in the middle of a problem? You can then resolve the issue through conditional breakpoints. When debugging the loop code, there is a value that we pay particular attention to when we look at the value of the variable in the Variable tag , for example, we pay more attention to sum at this time, and each step can see the sum change.

To set a conditional breakpoint, we right-click on the left side of line 11th and select Breakpoint Properties ... Get:

(c) Practice

1, through the command line and Eclipse two ways to achieve, their study number after the two and the total number of topics to take the remainder of the result plus 1 is the title number:

Eclipse Mode:

Command line:

2, the choice is to realize the Fibonacci sequence function:

Eclipse Mode:

Command line:

Third, the problems encountered and solutions

Problems encountered:

1, virtual machine a bit card 2, Eclipse input error when there is no time to enter 3, programming is not skilled, input code unfamiliar

Solution: Usually more knock code, do high School

Iv. Harvest of Experiments

Harvest: 1, preliminary understanding of the Linux system under some basic command 2, learned the simple editing of Eclipse, compile, run, Debug 3, aware of the code compilation defects

Java Experiment One

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.