Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
abo-1.0.jar - Maven Test Project Target
How to generate my Maven project target file, *.jar?
✍: FYIcenter.com
If you Maven project package target is a JAR file,
you can use the "mvn package" command to generate the target file:
fyicenter\abo> ..\apache-maven-3.5.4\bin\mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------- com.fyicenter:abo >-------------------------- [INFO] Building Apple, Banana and Orange 1.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ abo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\fyicenter\abo\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ abo --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ abo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\fyicenter\abo\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ abo --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ abo --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ abo --- [INFO] Building jar: C:\fyicenter\abo\target\abo-1.0.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.111 s [INFO] ------------------------------------------------------------------------
The target JAR file should be located in .\target folder:
fyicenter\abo> tree /f .
│ pom.xml
│
├───src
│ └───main
│ └───java
│ └───com
│ └───fyicenter
│ TreeListExample.java
│
└───target
│ abo-1.0.jar
│
├───classes
│ └───com
│ └───fyicenter
│ TreeListExample.class
...
You need to copy dependency JAR files to the project, so you can run the target JAR file:
fyicenter\abo> ..\apache-maven-3.5.4\bin\mvn dependency:copy-dependencies [INFO] Scanning for projects... [INFO] [INFO] ------------------------- com.fyicenter:abo >-------------------------- [INFO] Building Apple, Banana and Orange 1.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ abo --- [INFO] Copying commons-collections4-4.2.jar to C:\fyicenter\abo\target\dependency\commons-collections4-4.2.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.543 s [INFO] ------------------------------------------------------------------------
Now you can run the target JAR file:
fyicenter\abo> ..\jdk-1.8.0\bin\java -cp .\target\abo-1.0.jar;.\target\dependency\commons-collections4-4.2.jar com.fyicenter.TreeListExample 0: Banana 1: Apple 2: Orange 3: Apple 4: Orange 5: Apple
The target JAR file, abo-1.0.jar, is good.
2020-10-10, ∼1825🔥, 0💬
Popular Posts:
What Is HttpComponents commons-httpclient-3.1.j ar?HttpComponents commons-httpclient-3.1.j aris the ...
JDK 11 jdk.hotspot.agent.jmod is the JMOD file for JDK 11 Hotspot Agent module. JDK 11 Hotspot Agent...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
How to download and install JDK (Java Development Kit) 8? If you want to write Java applications, yo...
JDK 11 jdk.httpserver.jmod is the JMOD file for JDK 11 HTTP Server module. JDK 11 HTTP Server module...