Experiment with familiarity with a Java development environment

Source: Internet
Author: User

Beijing Institute of Electronic Technology (BESTI)

Lab Report

Course: Java Lab class: 1352 Name: He Weizin No.: 20135223

Score: Instructor: Lou Jia Peng Experimental Date: 2015.4.15

Experiment level: Preview degree: Experiment time:

Instrument Group: 05 Compulsory/Elective: Compulsory experiment serial number: 01

Lab name: Familiarity with Java program development environment

Experimental purposes and requirements: 1. Implement Java Program development under command line;

2. Implement Java program development under Eclipse.

Experimental instrument:

Name

Model

Number

Eclipse

\

1

Virtual machines

\

1

Experimental content 1. Compile and run a simple Java program using the JDK; 2. Edit, compile, run, and debug Java programs using Eclipse. Experimental knowledge point 1. Installation location and difference of JVM, JRE, JDK, 2. command line run JAVAC;JAVA;JAVAC-CP; Java-cp;3. Path,classpath,sourcepath setting method and application; 4. Package management: package;import;javac-d; 5. Eclipse (Netbeans) manages Java projects, debugging: breakpoints, stepping, etc.; 6. Java basic syntax: type and type conversion; variables; operators; flow control etc; 7. The use of the JDK help documentation.

Experimental steps

(i) Java program Development under command line

1. First double-click the Xface terminal icon on the desktop.

2. Open the terminal (similar to CMD in Windows) and then run the shell program automatically.

3. Enter the CD Code command to enter the code (note C to capitalize) directory.

4. Enter the mkdir 20135100 command to establish the experimental directory, note that the directory name must be its own school number (study number to be reflected in the experimental report), you can use the LS command or the dir command to view the established directory situation.

5. Enter the CD 20135100 command into the experimental directory, and then enter a similar mkdir EXP1 to create 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.

6. Enter Gedit Hello.java (note Save the code in the EXP1 directory) or vim Hello.java edit Hello.java.

7. 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 command on the command line and return or click the Eclipse EE icon on the desktop to open eclipse.

2. In eclipse, click File->new-> Java Project to create new Java projects.

3. Enter the project name Hellojdb (you can do it yourself) and click the Finish button to complete the new project.

4. In eclipse, click File->new->class to create a new Java class.

5. Enter the package name LJP (lowercase, can be customized) according to the Java code specification, the class name Hellojdb (capitalize the first letter of the word), and tick the Automatically generate main function option, and then click the Finish button.

6. Enter the following code:

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

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

9. The debugger first sets breakpoints and one-step operation.

10. 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).

11. 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, each step can see the sum change, set the conditional breakpoint, we left the 11th row right mouse button, select.

(c) Exercise 3. Implement the Fibonacci sequence function and test. Code:

Package hwq;

Import Java.util.Scanner;

public class Fibonacci {

public static void Main (string[] args)

{

Scanner s = new Scanner (system.in);

System.out.print ("Please input N:");

int n = s.nextint ();

int result;

for (int i = 1; I <= n; i++)

{

result = Fibonacci (i);

SYSTEM.OUT.PRINTLN (result);

}

}

public static int Fibonacci (int n)

{

if (n <2) {

return 1;

}

else{

Return (Fibonacci (n-1) + Fibonacci (n-2));

}

}

}

(d) PSP Statistics:

Steps

Time-consuming (min)

Percentage

Demand analysis

5

6.6%

Design

15

20%

Test

30

60g

Analysis Summary

25

33.3%

(v) Problems encountered and solutions

1. Experimental building Linus Environment too card, unable to successfully finish the experiment, so the first experiment in the experimental building, the second experiment in their own computer eclipse do.

2.gedit Hello.java input Error, a series of not understand the hint, after a careful examination of the control samples found correct

3. The code has a package compile, add the-D function, but do not have the correct input space, resulting in a compilation error. Later found in-D. Add a space around this point to

4. In the Fibonacci sequence, return (Fibonacci (n-1) + Fibonacci (n-2)); The plus sign hits the *, although the program runs out, but the expected results cannot occur. Re-use breakpoints and some experience corrections after displaying problems in Eclipse compilation.

(vi) Experimental experience

1. Despite the success of the experiment, it found itself a lot of shortcomings: first spent too much time, the first experiment and the second experiment need to do the template, and still have a lot of errors, in the third experiment, a long time without thinking, and finally need to consult the book, and in the programming process is very inefficient, Often make some low-level details mistakes. It can be imagined that their programming base is very poor, programming ability has yet to be improved.

2. At the same time, through this experiment, further familiar with command line and Eclipse Java program Development using JDK compiled, run a simple Java program, to edit in Eclipse, compile, run, debugging Java programs have more familiar with the use of knowledge, a lot of harvest.

3. After training, accumulate and improve.

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.