Familiarity with the Java development environment

Source: Internet
Author: User

Beijing Institute of Electronic Technology (BESTI)
Lab Report
Course: Java Programming Class: 1352 Name: Malmqvist No.: 20135235
Score: Instructor: Lou Jia Peng Experimental Date: 2015.4.13
Experiment level: Preview degree: Experiment time: 20:30---22:30
Instrument Group: compulsory/Elective: Elective experiment number: 1
Lab Name: Familiarity with the Java development environment
experimental purposes and requirements: 1. Use the JDK to compile and run simple Java programs.
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 ThinkPad 1
Virtual Machine Lab 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 20135235 command to establish the experimental directory, you can use the LS command or the dir command to view the established directory situation.
(3) Enter the CD 20135235 command into the experimental directory, 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) Enter Gedit Hello.java (note Save the code in the EXP1 directory) or Vim Hello.java (it is recommended that 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}
Ten}
Notice the first line of the code, which affects how we compile the code using JAVAC.
note in the second line of 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 in the C language), the import path can view the JDK Help documentation, for example, we use the scanner class, the path is shown in the red box:
(6) Enter javac-d. Hello.java command to compile the code, enter the Java HYQ. The Hello command runs the program. (already in the experimental building)
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 Hellojdb and 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 HyQ 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, Exercise: study number after two to take the remainder--1th: The implementation of Caesar password, and test
import Java.util.Scanner;
Public class Caeser {
private String table; Defining the key alphabet
private int key;//define key
Public caeser (String table, int key) {
//Generate a new Caesar algorithm based on different alphabets and different keys to achieve general purpose
super ();
this.table = table;
This.key = key;
}
Public string Encrypt (string from) {
//Caesar encryption algorithm, incoming plaintext string, return a ciphertext string
String to = "";
for (int i = 0; i < from.length (); i++) {
to + = Table.charat ((Table.indexof (From.charat (i) +key)%table.length ());
}
return to;
}

Public static void Main (string[] args) {
Caeser Caeser = new Caeser ("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3);
Scanner Scanner = new Scanner (system.in);
System.out.println ("Please enter a string to encrypt");
String str =scanner.nextline (); Input string
String result = Caeser.encrypt (str); Call encryption method for encryption
System.out.print (Result); Can get results
}
}

second, the experimental analysis
1. My PSP time
Step Time-consuming percentage
Demand Analysis 5 10%
Design 5 10%
code implementation Ten 20%
Test 40%
Analysis Summary of 20%

third, the experimental thoughts
The experiment was the first time to use a lab building, a virtual machine, and a Linux environment. The steps in the experiment are very detailed, and the experiment is done in step and steps according to the test set by the teacher. But there are a lot of problems: the Linux command line operation is not proficient. In this experiment, you basically mastered the use of creating a directory (mkdir), viewing the directory (ls or dir), entering the directory (CD is the same as Windows), and viewing the current working path (PWD). Compile a. java file format: javac-d. Class name. Java (note: There are spaces before and after the point in D) run the file format: Java package name. Class name. After entering the code in Eclipse, the teacher has been unable to compile successfully, repeatedly check, found that the package was created when the automatic generation of the main function, and I write the code when I hit a lot of curly braces, causing the error will not compile.
through this experiment, we learn more about Linux environment, learn how to debug code errors, set breakpoints, single-step operation, change the efficiency of single-step operation and the use of some shortcut keys. Harvest a lot, in the future will practice, and hope to do better.

Familiarity with the Java development environment

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.