Home > Java > javaTutorial > body text

How to run java class file

coldplay.xixi
Release: 2020-08-21 10:33:35
Original
10493 people have browsed it

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 ], the command line is [java .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文件名>
Copy after login

Note: Do not include the file suffix .class

in the CLASS file name. For example:

The code is as follows:

java Test
Copy after login

If the executed class file is packaged, that is, it is used in the class file: package <package name>

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

java <包名>.CLASS文件名
Copy after login

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

package com.ee2ee.test;
Copy after login

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
Copy after login

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

The code is as follows:

java com.ee2ee.test.PackageTest
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!