In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use OpenJDK source code to implement HelloWorld, the quality of the article is high, so Xiaobian shares it with you as a reference, I hope you have a certain understanding of related knowledge after reading this article.
HelloWorld in Java
Usually when we run java programs, there are generally two options, 1 is to run the program directly on the server with java -jar command, 2 is to click Run/debug directly in idea, as shown in the following figure:
What if one day we get out of idea and we run this on the command line?
In fact, idea has already helped us generate, as shown in the first line of the figure below
We take the following from above, copy it to the command line, and we run it.
/Users/lixiang/soft/jdk-11.0.2.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/lixiang/code/tools/tools-java/out/production/classes com.platform.tools.jvm.Main
This is shown in Figure 1.
Run java code in CLON
Run java code in Clion, mainly the java command in front, compiled by ourselves, and then directly copy the parameters behind it, as shown in the following figure:
Then click Run and you will see our java code output as shown below in the ClionDebug panel
JVM executes Java code
Here we're going to continue with yesterday's version number output. In java.c file line 508, you can see the class where the main function is loaded.
After clicking on it, you can see it. In fact, it is still the java class requested, as shown in the following figure:
1. Go and find this class dot. After entering, you can see that it is this class sun/launcher/LauncherHelper.
2. Find the checkAndLoadMain method in the class above
3. This method has Z(Boolean),I(integer type),String type input parameters
The return value of this method is Class.
Based on this condition, we can find the following method in Idea
Then we trace it all the way down, you can see, finally to the ClassLoader.java defineClass1 this native method,native method and jdk source code corresponding to us later together to learn.
After the LoadMainClass() method, we can see CreateApplicationArgs creating the application's parameter method, looking for the Main method, executing the Main method, as follows:
About how to use OpenJDK source code to implement HelloWorld to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.