Experiment a familiar experiment content of Java development environment
1. Compile and run a simple Java program using the JDK;
2. Edit, compile, run, and debug Java programs using Eclipse.
Experimental knowledge points
1.JVM, JRE, JDK installation location and difference;
2. command line run JAVAC;JAVA;JAVAC-CP; JAVA-CP;
The setting method and application of 3.path,classpath,sourcepath;
4. Package management: package;import;javac-d;
5.Eclipse (Netbeans) manages Java projects, debugging: Breakpoints, single step execution, etc.;
6.Java basic syntax: type and type conversion; variables; operators; Process control, etc.;
The use of 7.JDK help documents.
Experimental stepsone, the use of JDK compiled, run a simple Java program;
First, edit the environment variables to use Javac and Java in the JDK for flanging;
Javac is a compilation tool;
Java is a running tool;
Write a simple program with text;
The code is as follows:
The results of the operation are as follows:
second, the idea under the Java program development, debugging
To establish a new project;
Then create a new class;
Write code;
Run the program;
Third, practice the implementation of Caesar password
Component: Main function (choose encryption or decryption), decryption class, encryption class;
Code:
ImportJava.io.*;ImportJava.util.Scanner; Public classKaisa { Public Static voidMain (string[] args) {System.out.println ("Input" 1 "encryption; input" 2 "decryption"); Scanner C=NewScanner (system.in); intb =C.nextint (); if(b = = 1) {System.out.print ("Please enter the secret key:"); Scanner s=NewScanner (system.in); intA =S.nextint (); C (a); } Else if(b = = 2) {System.out.print ("Please enter the secret key:"); Scanner s=NewScanner (system.in); intA =S.nextint (); B (a); } } Public Static voidCintN) {Try { Charb[]; BufferedReader Br2=NewBufferedReader (NewInputStreamReader (system.in)); System.out.println ("Please enter a clear text:"); String str2=Br2.readline (); b=Str2.tochararray (); System.out.println ("Ciphertext is:"); intK =N; for(inti = 0; I < str2.length (); i++) { CharCH = (Char) ((B[i]-' a ' + k)% + ' a '); System.out.print (CH); } System.out.println ("Key k=" +k); } Catch(IOException e) {System.out.println (E.getmessage ()); } } Public Static voidBintm) {Try { Charb[]; BufferedReader Br2=NewBufferedReader (NewInputStreamReader (system.in)); System.out.println ("Please enter a cipher:"); String str2=Br2.readline (); b=Str2.tochararray (); System.out.println ("Clear text is:"); intk=m; for(intI=0;i<str2.length (); i++) { CharCh= (Char) ((b[i]-' a '-K)%26+ ' a '); System.out.print (CH); } System.out.println ("Key k=" +k); }Catch(IOException e) {System.out.println (E.getmessage ()); }}}
Operation Result:
20145235 The first experimental report on Java programming