Beijing Institute of Electronic Technology (Besti)
Actual inspection report
Course:Java Programming Class: 1353 Name: Li Sheli No.:20135309
Score: Instructor: Lou Jia Peng Experimental Date: 2015.4.15
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. Compile and run a simple Java program using the JDK.
2. Edit, compile, run, and debug simple Java programs under command line and Eclipse.
3. Students who do not have a Linux base are advised to start with the Linux basics (new version) Vim Editor course.
Experimental instrument:
Name |
Model |
Number |
Pc |
Lenovo |
1 |
Virtual machines |
Laboratory Building |
1 |
First, the experimental steps
1. Program development of Java under command line
(1) First double-click the Xface terminal icon on the desktop to open the terminal (like cmd in Windows ) and then run the shell program automatically.
(2) Enter the CD Code command to enter the code(note C to uppercase) directory, enter the mkdir 20135309 command to establish the experimental directory, you can use the ls command or dir command to view the established directory situation.
(3) Enter the CD 20135309 command into the experimental directory, and then enter 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.
(4 ) input Gedit hello.java exp1 directory) or vim hello.java (suggest you take some time to learn vim Edit Hello.java, and enter the following code:
1 package ljp;2 import java.util.scanner;3 public class Hello{4 public static void main (String[] args) {5 system.out.println ("Input your first name, please:");6 scanner s = new scanner (system.in);7 string name = s.next (); 8 system.out.println (" hello " + name + " ! "); 9 }10 }
Notice the first line of the code, which affects how we compile the code using JAVAC. note in the second line of the code, when we use the class in the Java class Library to import the related classes with import (which can be temporarily understood as features of include in C ), the import path can view the JDK Help documentation, For example, we use the scanner class, the path is seen in the red box:
(6) Enter javac-d. Hello.java command to compile the code, enter the Java WJQ. The Hello command runs the program as shown in the results:
2. Java program development and debugging under Eclipse
(1) Enter the Eclipse command at the command line and enter 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. Enter the project name Hellojdband click the finish button to complete the new project.
(3) in Eclipse, click File->new->class to Create a new Java class.
(4) Enter the package name WJQ according to the Java code specification, the class name Hellojdb, and tick the Automatically generate main function option, and then click the Finish button.
(5) Enter the code and click the Run button (or use the ctrl+f11 shortcut)to see the results of the run in the console.
(6) Debug program. Open the Debug view by clicking Window->open perspective->debug .
(7) set breakpoints and single step operation. To set a conditional breakpoint, right-click on the left side of the accumulation and select Breakpoint Properties. Enter the condition, press F8 to run to condition stop.
3. Practice:
Implements the function of finding All prime numbers between positive integer 1-n and testing.
The code is as follows:
Import Java.util.Scanner; public class Prime {public static void main (string[] args) {Scanner s=new Scanner (system.in); System.out.println ("Input N:"); int N=s.nextint (); System.out.println ("Prime is:"); go:for (int i = 2; i < n; i++) {for (int j = 2; J < I; J + +) {if (i% j = 0) continue go;} System.out.print ("" + i);}}}
Ii. problems encountered and their solutions
1, the experimental building resources and operating methods are not familiar, and finally in the windows conditions to complete the experiment.
2, project naming because of the operation process to quit, the second use of new must change a name, mainly English interface is not proficient, the software is not familiar with. Later on the replacement of the file name re-do, follow the teacher's steps to boldly try, and then need to spend more time familiar with these operations.
3, in the process of the preparation of prime numbers, through the search for help files and Baidu, understand the input method in scanner: int n=s.nextint ();
Third, the experimental Harvest
The laboratory according to the experimental requirements under Windows conditions, the teacher gave the steps very detailed, I feel that learning these processes is not particularly difficult. Encountered the main problem is the use of software is not familiar with the use of English interface is not used, need to practice, skilled use of some tools and help files. Through this experiment operation, learned the use of Scanner and the use of the package, but also familiar with some software operating methods.
First Test report of experimental building