当前位置:网站首页>DOS command virtual environment

DOS command virtual environment

2022-06-11 09:19:00 lwj_ 07

 common DOS command :
exit   Quit current DOS Command window 
cls  Clear the screen 
dir  List all the sub files in the current directory / subdirectories 
cd  command :
cd  Path to directory 
 But paths include absolute paths and relative paths 
 Absolute path : Indicates the path from the drive letter of a disk as the starting point 
 Relative paths : Indicates the path from the current path as the starting point 
cd..  Go back to the parent directory 
cd\   Back to root 
del *class :  eliminate class Source file 

 How to switch drive letters :
 c: enter 
 d: enter 
 f: enter 
 e: enter 

 8、 About widows Setting the file extension of the operating system :
   As java The programmer , To create a new one later .java Final document , So you must ensure that the file extension is .java
   How to do it? ?
    Turn on the computer ---》  see  ---》  Hide file type extensions ( Remove the check mark in the front )

9、 java  Compile phase   Operation phase 

JDK After the installation is completed, except for a self-contained javac.exe outside , There's another tool / command , be called java.exe
java.exe Mainly responsible for the operation stage .
    -java.exe Where can I use ?  How to use it? ?
 	 stay DOS Use... In the window 
	java.exe How to do? ?
	java  Class name 
	 for example :
		 There's one on the hard disk A.class  Then use it like this : java A
		 Be careful : Don't write like this :java A.class [ FALSE ]
    -javac How to do? ? Where can I use it ?
    	-javac Rules of use :
		javac java Path to source file 
	- stay DOS Use... In the window 
      javac It's a java Compiler tools / command 

 The process of the operational phase is :
	* open DOS Command window 
	* Input :java A
	*java.exe Command will start java virtual machine (JVM),JVM Will start class loader ClassLoader
	*ClassLoader I'm going to search the hard disk A.class file , If the file is found, load the bytecode file to JVM among 
	*JVM take A.class Bytecode files are interpreted as binary 101010101010 Data like this 
	* Then the operating system performs binary and interacts with the underlying hardware platform 


10、  Start the first one java Program 
	*  Make sure you have a text compiler installed on your computer Editplus
	*  install JDK
	
	JDK Introduction to the catalogue :
	JDK/bin:  There are many commands in this directory , for example javac.ex and java.exe
	javac.exe Responsible for compiling 
	java.exe Responsible for operation  

* compile java Program :

	 Development HelloWorld.java Source program  【  To copy verbatim , Don't ask why , Pay attention to case 】
	-  take HelloWorld.java Source program through javac Tools to compile :

		 The first problem to be solved is :javac Is the command available 
		*  open DOS Command window , Direct input javac  And then go back , The following appears :
		'javac'  Not an internal or external command , It's not a runnable program 
		 Or batch files .
		 The above problems are due to : windows The operating system could not find javac Command file 

	   - How to solve the above problems javac The problem of unavailability ? (  Configure environment variables )
		windows How does the operating system search for a command on the hard disk ?	
		* First, it will search from the current directory 
		* If the current directory cannot be searched , From environment variables path Search the specified path for a command 
		* If you can't find them all , The above error is reported .
	   - javac How to use the order ?
		javac java Source file path 
		 Be careful : Path includes relative path and absolute path , Fine .

* function java Program :
	- Need to use java.exe command 
	- First test java Is the command available 
	- Usage mode :
	java  Class name 
	 On the hard disk HelloWorld.class, So the class name is : HelloWorld
	java HelloWorld
	 Be sure to pay attention to :java The command is not followed by a file path , Is the name of a class .
	 First of all, you need to put DOS The directory in the window switches to Hel1oWorld.class File directory .
	 And then directly execute : java Helloworld


	*java How to write the notes in ?
	- Single-line comments 
		// Single-line comments , Comment only the current line 
	- Multiline comment 
		/*
		 Multiline comment 
		 Multiline comment 
		 Multiline comment 
		 Multiline comment 
		 Multiline comment 
		*/
	 One javadoc notes 
	/**
	*   javadoc notes 
	*   javadoc notes 
	*   javadoc notes 
	*/
	 Be careful : This kind of annotation is more professional , The annotation information will be javadoc.exe The tool parses, extracts and generates help documents .

 

 1、 Development HelloWorld.java Source program and comments

// public  Public 
// class  class 
// HelloWorld  Class name 

public class HelloWorld{   //  Represents the definition of an open class   Naming HelloWorld
//  The class body  【  remember  】 
	//  Direct writing of... Is not allowed in class bodies java sentence 【 In addition to declaring variables 】
	// System.out.println("Hello World!");


	/*  public  Open 
		static  Static 
		void  empty 
		main  Method 
		(String[] args)  It's a main Method's formal parameter list 
		 Here's the thing to remember : 
			 The following method is a program " Main method ", Is the execution entry of the program 
		public static void main(String[] args)   Represents the definition of an exposed static main method 
	*/
	public static void main(String[] args){

		//  Method body 
		//  Method body 
		//  Method body 
		System.out.println("Hello World!");
		//  Output a Chinese 
		System.out.println(" Hello !");
		System.out.println(" I am a 'dsb'");
	}
}

 2、public class and class The difference between

         * One java Multiple... Can be defined in the source file class

      

        * One java In the source file public Of class It's not necessary

        * One class Will generate a definition of xxx.class Bytecode file

 

        * One java If the public class is defined in the source file ,public Of class There can only be one , And the class name must be the same as java Source file names are consistent       Otherwise, the report is wrong :

        * every last class You can write main Method , You can set the program entry , Want to execute A.class Medium main Method : java B

        Be careful : When executed in a command xxx.class There must be... In the time program main Main method There is no master method, and there will be runtime errors

原网站

版权声明
本文为[lwj_ 07]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020507216737.html