Java Pre-development trivia

Source: Internet
Author: User

1. Common DOS commands

Drive letter: Enter the specified drive letter.

dir : Lists the files and folders in the current directory

MD: Creating a Directory

Rd : Delete directory Note: Rd cannot delete non-empty folders, and can only be used to delete folders.

CD : Enter the specified directory

CD : Back to top level directory

CD \ : Go back to the root directory

echo "Hello java" >a.txt writing text to the specified file

type a.txt display file Contents command

del : Delete file Note: You cannot delete a folder, only files can be deleted.

exit : Launch DOS command line

CLS : Notifies the computer to empty the current command

*: is a wildcard character.

tab Command completion.

The arrow keys are up and down to retrieve the last command you wrote.

2. Cross-platform

That is, it does not depend on the operating system, nor does it trust the hardware environment. Applications developed under one operating system can still run under another operating system. Java's cross-platform is implemented through a Java Virtual machine (JVM).

3. Java VM (Jvm:java virtual machine)

The JVM is at the bottom of the entire JDK and is responsible for the interaction of the operating system, which masks the operating system environment, provides a complete Java runtime environment, and therefore the virtual machine. The Java source program is imagined as our C source program, and the bytecode (. Class) generated by the Java source program is equivalent to the compiled binary executable file of the C source program. The JVM virtual machine is equivalent to a computer system (operating system + hardware environment) and the Java interpreter is CPU.

. exe files run directly under the Windows operating system and are machine code (. exe files) running on the CPU

The. Class bytecode file is run under the JVM virtual machine, and Java bytecode is running on the Java interpreter.

The Java interpreter is equivalent to "CPU" running Java bytecode, but the "CPU" is implemented by software instead of hardware. The Java interpreter is actually an application under a particular platform. As long as the interpreter program under a specific platform is implemented, Java bytecode can be run through the interpreter program on the platform, which is the root of the Java cross-platform. Currently, not all platforms have a corresponding Java interpreter program, which is why Java does not work on all platforms, it can only run in the implementation of the Java Interpreter program platform.

4.JDK Catalogue Introduction
    1. Bin directory: A compiler, interpreter, and other tools (executables) that store java.
    2. DB directory: JDK7 comes with a lightweight database named Derby.
    3. Include directory: an interface file that holds the calling system resource.
    4. JRE Directory: Store Java Runtime Environment files.
    5. LIB directory: A class library file that holds java.
    6. Src.zip file: The source code for the class provided by the JDK.

things to keep in mind when installing a JDK: 1 . Do not include Chinese in the installation path . 2 . Do not include spaces in the installation path.

JRE (Java Runtime Environment Java) Runtime environment. Including the core class libraries required for Java virtual machines and Java programs, if you want to run a well-developed Java program, you only need to install the JRE on your computer.

JRE = JVM + Core Class Library

JDK = JRE + Java development tools (Java compiler, etc.)

5. Configure the PATH environment variable

Problems with the compilation process: each time you compile, you need to write the full path to the Java source file (). Bother!

Solution: If you can find Java development tools under any path, the problem is solved.

Currently under the console window can only be used in the JDK directory of the directory to use the JDK development tools under the control, if you want to use in any directory under the console window Javac with Java or other development tools of the JDK what should be done?

5.1. On the DOS window, hit Javac.

When we hit Javac or Java commands in a random directory, we found that the DOS window shows this is not an internal command, and then when we hit the Notepad command on it, we opened a Notepad program. However, there is no executable file with Notepad.exe in the current directory, so why do I start it?

Error reason: The original in the DOS window to write a command, if the current directory can not find the specified executable, then it will be based on the PATH environment variable saved to search for the existence of the executable file, if there is to start the program, otherwise there is no such command.

5.2. Workaround:

1. Enter the bin directory of the JDK's installation directory.

2, on the DOS command to knock Javac. (If the above diagram information is present, the configuration is successful)

5.3 Why configure the PATH environment variable: the Java development tool can be found under any path 5.4 the name of the. class file generated by Javac depends on the class name, which is not related to the. Java name. 6. CLASSPATH environment variable: Sets the path information for the class file. 6.1. Introduction of Classpath:

Compiled Hello.class file on F-disk, current path in e-drive, direct input command

Java Hello Run class file, error, no class found ....

6.2 Settlement:

Since the class file (bytecode file) is Java's running file, can it be implemented, in any directory will be able to execute a directory of the class file? Depending on the principle of the PATH environment variable, you can define an environment variable named CLASSPATH, which is defined in the same directory as the class file that will run. For example set classpath=f:\ However, this setting is a temporary variable. How can it be once and for all? Setting CLASSPATH Environment variables

If you want to use a class that has already been written, you can certainly find them. (1) When the CLASSPATH environment variable is not set, when the JVM (Java Virtual machine) is started, the Java Virtual machine will look for the corresponding class file under the current path. (2) When the CLASSPATH environment variable is set, the JVM will look for the corresponding class file according to the path information saved by the CLASSPATH environment variable.

There is a semicolon and no semicolon for setting CLASSPATH environment variable information: The semicolon is equivalent to the current path. 1. If the configuration classpath environment variable information does not include a semicolon, then the JVM will only search for the corresponding class file in the path saved by Classpath, and will not search the current path. 2. If you configure the CLASSPATH environment variable information with a semicolon, the JVM will search for the corresponding class file in addition to the path saved by Classpath, if it can find the corresponding class file. Then specify the corresponding class file immediately, otherwise The current path goes down the search.

Is 7.Java a compiled or interpreted language?

Compiled languages: After the source program is compiled, the language of the binary files that the system can run directly is generated.

Interpreted language: Translate a good source program into one sentence, then execute one sentence until the end!

In my opinion, Java is an interpreted language, because although Java also needs to be compiled and compiled into a. class file,

But it's not the language that the machine recognizes, it's bytecode, and ultimately it needs the JVM's explanation to execute on every platform, and that's why it's a cross-platform for Java. So Java is a compiled and interpreted type.

What form does 8.JVM exist in, and is it included in the JDK? What's his file name?

Inside the JDK, it is javaw.exe, because every time eclipse starts, there is javaw.exe this process. The JVM is the environment in which the Java program runs, but he also has a process for an application of an operating system, so he has his own running life cycle, It also has its own code and data space. The operating system is loaded into the JVM via Java.exe in the JDK, completing the JVM environment in 4 steps below.  1. Create the JVM loading environment and configuration;  2. Loading Jvm.dll;  3. Initialize Jvm.dll and hang bounds to jnienv (JNI call interface) instance; 4. Call the JNIEnv instance to mount and process the class.

Java Pre-development trivia

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.