First, run the class file
Executes the class file with the main method, and the Java Virtual Machine command parameter behavior:
Java <class file name >
Note: The class file name does not have a file suffix. class
For example:
Java Test
If the executing class file is wrapped, it is used in the class file:
Package < package name >
That should be executed under the base path of the package, Java Virtual machine command-line arguments:
Java < package name. Class filename
For example:
In Packagetest.java, the package name is: Com.ee2ee.test, and the corresponding statement is:
Package com.ee2ee.test;
The Packagetest.java and compiled class file Packagetest.class directory is as follows:
Classes
|__com
|__ee2ee
|__test
|__packagetest.java
|__packagetest.class
To run Packagetest.class, you should execute it in the classes directory:
Java com.ee2ee.test.PackageTest
Second, run the class in the Jar file
Principle and run class file, just add parameter-cp <jar filename > can.
For example, to perform the class com.ee2ee.test.PackageTest in Test.jar, the command line is as follows:
JAVA-CP Test.jar Com.ee2ee.test.PackageTest
Third, display JDK version information
When you have more than one JDK version on a machine, you need to know that you are currently using that version of the JDK, using the parameter-version to know its version, command behavior:
Java-version
Iv. increase the maximum memory available to the virtual machine
The maximum memory that can be used by a Java Virtual machine is limited, and the default value is usually 64MB or 128MB.
If an application uses more memory to load data into memory in order to improve performance, such as exceeding the default maximum of 128MB, you need to increase the maximum amount of memory available to the Java virtual machine, otherwise there will be an out of Memory (low system memory) exception. When you start Java, you need to use the following two parameters:
-XMS the memory size used when Java Virtual machine initialization
-XMX the maximum memory that Java virtual machines can use
Size, set in the above two command-line arguments, can be in units, for example: 256m means 256MB
An example is provided:
java-xms128m-xmx256m ...
Indicates that the memory used for Java Virtual machine initialization is 128MB and the maximum memory available is 256MB.
For Tomcat, you can modify its script catalina.sh (Unix platform) or Catalina.bat (Windows platform) and set variable java_opts, for example:
java_opts= '-xms128m-xmx256m '