dnf install java-17-konajdk -y
java -version
openjdk 17.0.3-ga 2022-04-19OpenJDK Runtime Environment TencentKonaJDK (build 17.0.3-ga+1)OpenJDK 64-Bit Server VM TencentKonaJDK (build 17.0.3-ga+1, mixed mode, sharing)
dnf install java-11-konajdk -y
java -version
openjdk 11.0.18-ga 2023-01-17OpenJDK Runtime Environment TencentKonaJDK (build 11.0.18-ga+1)OpenJDK 64-Bit Server VM TencentKonaJDK (build 11.0.18-ga+1, mixed mode, sharing)
dnf install java-8-konajdk -y
java -version
openjdk version "1.8.0_322"OpenJDK Runtime Environment (Tencent Kona 8.0.13) (build 1.8.0_322-1)OpenJDK 64-Bit Server VM (Tencent Kona 8.0.13) (build 25.322-b1, mixed mode, sharing)
alternatives --config java
dnf remove java-17-konajdk-headless -y
dnf remove java-11-konajdk-headless -y
dnf remove java-8-konajdk-headless -y
MyFirstClass.java is as follows:public class MyFirstClass {public static void main(String... args) {System.out.println("Hello, World!");}}
java MyFirstClass.java
java -version
dnf install java-17-konajdk-devel
javac MyFirstClass.java
java MyFirstClass
dnf install apache-commons-cli -y
apache-commons-cli module package.dnf install maven maven-openjdk17 -y
mvn -v
Apache Maven 3.8.6Maven home: /usr/share/mavenJava version: 17.0.3-ga, vendor: Tencent Company, runtime: /usr/lib/jvm/java-17-konajdkDefault locale: zh_CN, platform encoding: UTF-8OS name: "linux", arch: "x86_64", family: "unix"
maven-openjdk version does not meet your requirements, uninstall the current maven-openjdk version first, and then install another version.mvn archetype:generate -DgroupId=com.testmaven.myfirstapp -DartifactId=myfirstapp -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
maven project named myfirstapp and automatically download the required plugin packages from the maven central repository. By default, the plugin packages are stored in ~/.m2.myfirstapp/├── pom.xml└── src├── main│ └── java│ └── com│ └── testmaven│ └── myfirstapp│ └── App.java└── test└── java└── com└── testmaven└── myfirstapp└── AppTest.java
pom.xml is the maven project configuration file, which contains basic project information, dependencies, build methods, and more.src/main/java stores the project source code.src/main/java stores the project test source code.<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.testmaven.myfirstapp</groupId><artifactId>myfirstapp</artifactId><version>1.0-SNAPSHOT</version><name>myfirstapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.7</maven.compiler.source><maven.compiler.target>1.7</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency></dependencies><build><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin>...</plugins></pluginManagement></build></project>
mvn package
[INFO] Scanning for projects...[INFO][INFO] ----------------< com.testmaven.myfirstapp:myfirstapp >-----------------[INFO] Building myfirstapp 1.0-SNAPSHOT[INFO] --------------------------------[ jar ]---------------------------------[INFO][INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ myfirstapp ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] skip non existing resourceDirectory /home/myfirstapp/src/main/resources...[INFO] -------------------------------------------------------[INFO] T E S T S[INFO] -------------------------------------------------------[INFO] Running com.testmaven.myfirstapp.AppTest[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 s - in com.testmaven.myfirstapp.AppTest[INFO][INFO] Results:[INFO][INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0[INFO][INFO][INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ myfirstapp ---[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.197 s[INFO] Finished at: 2023-05-26T11:59:51+08:00[INFO] ------------------------------------------------------------------------
jdb MyFirstClass.java
[root@localhost new]# jdb MyFirstClass.javaInitializing jdb ...> stop in MyFirstClass.mainDeferring breakpoint MyFirstClass.main.It will be set after the class is loaded.> runrun MyFirstClass.javaSet uncaught java.lang.ThrowableSet deferred uncaught java.lang.Throwable>VM Started: Set deferred breakpoint MyFirstClass.mainBreakpoint hit: "thread=main", MyFirstClass.main(), line=4 bci=04 System.out.println("Hello, World!");main[1] where[1] MyFirstClass.main (MyFirstClass.java:4)[2] jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (native method)[3] jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)[4] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)[5] java.lang.reflect.Method.invoke (Method.java:568)[6] com.sun.tools.javac.launcher.Main.execute (Main.java:419)[7] com.sun.tools.javac.launcher.Main.run (Main.java:192)[8] com.sun.tools.javac.launcher.Main.main (Main.java:132)main[1]
stop in command to set a breakpoint at the main function, and then run the program with the run command. After the program pauses at the breakpoint, use the where command to print the current call stack. To view more commands, enter the help command in the jdb interactive interface.Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários