In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to compile java into class files", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to compile java into a class file.
1. Overview
General generation compiles java into class files, which can be written as follows:
a)。 Javac [- cp xxx.jar] xxxx.java
b)。 Javac [- cp xxx.jar]-d. Xxxx.java
c)。 Javac [- cp xxx.jar]-d. / classes xxxx.java
First, the second way is to generate the class file in the current directory, and the third way is to generate the class file under the classes folder
Depending on whether there is a package name package in the xxx.java file, the path of the class file generated by the first and the two methods is also different, which is illustrated by an example:
The demo.java file is as follows (no package name package):
Public class demo {public static void main (String [] args) {System.out.println ("hello world!");}} 2. No package explanation
The first way to run the result:
The second way to run the result:
The third way to run the result:
3. When there is a package name
There is a package name in demo.java:
Package cj.test;public class demo {public static void main (String [] args) {System.out.println ("hello world!");}}
The first method cannot be executed after compilation:
The second way:
The third way:
4. Third-party jar
If you use a third-party jar package when compiling (the java file has the package name package, the third-party jar used is placed in the jar folder, and the compiled file is placed in classes):
That is:
Javac-cp compilation using jar file-d compiled class location xxx.java
Java-cp executes the class location; executes the third-party jar compiled class file used (including package name)
At this point, I believe you have a deeper understanding of "how to compile java into class files". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.