Experiment with familiarity with a Java development environment

Source: Internet
Author: User

Lesson: Java Programming Class: 1352

Name: Ellis No.: 20135210

Score: Instructor: Lou Jia Peng Experimental Date: 2015.04.17

Experiment level: Preview degree: Experiment time: 15:30~18:00

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

Lab name: Familiarity with the Java development environment

Experimental purposes and requirements:

Edit, compile, run, and debug simple Java programs under the command line and Eclipse

Experimental instrument:

Name

Model

Number

Pc

Macbook Air

1

First, the contents of the experiment:

1, the command line under the Java program development

2. Java program development and debugging under Eclipse

Second, the experimental process:

(i) Java program Development under command line

1. Open the terminal

2. Enter the command into the experiment directory

3. Enter the mkdir 20135100 command to create the experimental directory, note that the directory name is its own number, you can use the LS command or the dir command to view the established directory situation

4. Enter the CD 20135210 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 the PWD command to view the current working 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 Clare.hello command to run the program.

Also note: When you have a package in your code, you must add the- d parameter when you compile the code with JAVAC, and you must prefix the name with the packet when you run the code. Note the second line of code, when we use the class in the Java class Library, import the related class with import.

(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 Helloclare and click "Finish";

3. Open "File--new--class" in turn, in the popup dialog box, enter the package name: Clare, in the Name field to fill in the class name Helloclare, note the tick

3. Enter the code according to the title :

Package Clare;

public class Helloclare {
public static void Main (string[] args) {
int i=5;
int j=6;
int Sum=add (I,J);
SYSTEM.OUT.PRINTLN (sum);
sum=0;
for (i=0;i<100;i++)
Sum+=i;
SYSTEM.OUT.PRINTLN (sum);
}
public static int Add (int augend, int addend) {

int sum = augend + addend;

return sum;

}
}

4. Click the Run button 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 .

7. Step execution efficiency is slow, if we feel that the 6th line to the 10th line of code is no problem, want to let the program run directly to line 11th, what to do? First we'll set the breakpoint on line 11th 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 ...

(iii) Exercise (through command LineAnd EclipseImplemented in two ways, the results of the two and the total number of questions after their own study number plus 1Is the number you want to complete, practice debugging under Eclipse 1. Implement the Caesar password and test it.

(1) command line Run results

(2) Eclipse run result

Four

Experiment One:

Because the use of Mac OS system, command line execution statement and Linux, Windows are different, after Baidu, and then according to the combination of teaching pictures, finally debug the command line.

Experiment Two:

Experiments have made it more familiar to eclipse, and a new understanding of breakpoints has allowed you to debug your program more skillfully.

Experiment Three:

After Baidu, understand the history and origin of Caesar password. The process of writing a program is difficult, but when the program compiles successfully on the command line, the joy is palpable.

Five

Experiment experience: Try to experiment with experiment building environment several times, but fail, prompt "Insufficient system resources".

But because my computer is Mac OS System, the operation is not the same as windows, occasionally with the classmate's computer to compile, but also let me in a different system environment Java practice.

Every system environment language habits are different, through the Baidu search, I learned about OS system command line execution statement customary usage, the OS system has a deeper understanding. At the same time, through the teacher's Linux system, but also a general understanding of the Linux system under the command line interface.

SUBLIME_TEXT2 is used when compiling Java programs, but because of the error in Sublime's direct compilation function, it can only be compiled from the command line. This time, I realized that Eclipse was compiled directly and realized the ease of eclipse.

Experiment with familiarity with a Java development environment

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.