Home >Java >javaTutorial >How to run java class file

How to run java class file

coldplay.xixi
coldplay.xixiOriginal
2020-08-21 10:33:3510591browse

Methods for running java class files: 1. Execute the class file with the main method, the command line is [java]; 2. The executed class file is packaged, use [package] in the class file acab04e509e5b64e7e2bc0d60ab53414], the command line is [java acab04e509e5b64e7e2bc0d60ab53414.CLASS]. 文件名>

How to run java class file

Run the java class file method:

Execute the main method class file, the command line is:

java <CLASS文件名>

Note: Do not include the file suffix .class

in the CLASS file name. For example:

The code is as follows:

java Test

If the executed class file is packaged, that is, it is used in the class file: package acab04e509e5b64e7e2bc0d60ab53414

It should be under the base path of the package Execution, command line:

java <包名>.CLASS文件名

For example: in PackageTest.java, the package name is: com.ee2ee.test, the corresponding statement is:

package com.ee2ee.test;

PackageTest.java and the compiled class The storage directory of the file PackageTest.class is as follows:

classes
  |__com
      |__ee2ee
           |__test
                |__PackageTest.java
                |__PackageTest.class

To run PackageTest.class, it should be executed in the classes directory:

The code is as follows:

java com.ee2ee.test.PackageTest

Related learning Recommended: java basic tutorial

The above is the detailed content of How to run java class file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn