in Education by
I am creating a maven project from scratch, first just learn how to use maven. The main project contains no source code file, but it has two modules (app, and util). App depends on util. I would like to have a .jar from app, and have no manifest file if possible. I am able to compile the whole project with mvn clean install, but can not run the app from console. The main project .pom is 4.0.0 com.proba myproject 0.0.1 pom util app Util .pom is <?xml version="1.0"?> 4.0.0 com.proba myproject 0.0.1 util junit junit 3.8.1 test app pom is <?xml version="1.0"?> 4.0.0 com.proba myproject 0.0.1 app UTF-8 junit junit 3.8.1 test com.proba util 0.0.1 compile org.apache.maven.plugins maven-jar-plugin 2.4 com.proba.app.App true org.codehaus.mojo exec-maven-plugin 1.1.1 site-deploy java com.proba.app.App <!--<arguments> myArg1 myArg2 --> The code doesn't do too much. App.java (that inside the app module) is package com.proba.app; import com.proba.util.UtilClass; public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); UtilClass uc = new UtilClass(); System.out.println( "QQQQQ: " + uc.print() ); } } I compile it with mvn clean install [INFO] Reactor Summary: [INFO] [INFO] myproject .......................................... SUCCESS [ 0.406 s] [INFO] util ............................................... SUCCESS [ 2.074 s] [INFO] app ................................................ SUCCESS [ 0.535 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ myproject, util, app is SUCCESS. I try to run it with java -jar app/target/app-0.0.1.jar Hello World! Exception in thread "main" java.lang.NoClassDefFoundError: com/proba/util/UtilClass at com.proba.app.App.main(App.java:17) Caused by: java.lang.ClassNotFoundException: com.proba.util.UtilClass at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 1 more As you can see, Hello World! is printed out, but UtilClass is not found. I am able to run the build from eclipse, but not from the console. What I am doing wrong? Do you have any idea? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
What you missing is the jar of UtilClass. You just need to add shade plugin in your pom. As reference: maven-shade-plugin

Related questions

0 votes
    I am creating a maven project from scratch, first just learn how to use maven. The main project contains ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    When installing PDFBox with Maven, it places the libraries in the ~/.m2/repository directory. My program ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    This is my pretty simple C++/CMake .travis.yml env: global: # The next declaration is the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Maven command to create Java project is ____________. A. mvn archetype:generate -groupId=com.play ... artifactId=cucumber-jvm-maven -DarchetypeArtifactId=maven-archetype-quickstart...
asked Dec 13, 2022 in Technology by JackTerrance
0 votes
    The ________ project builds on top of pandas and matplotlib to provide easy plotting of data. (a) yhat ... and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    why android devolepor doesn’t use support android library for a large project? Select the correct answer from above options...
asked Dec 11, 2021 in Education by JackTerrance
0 votes
    I have a Maven build of a Java application that runs successfully on either Linux or Windows by typing the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I have a problem with Hibernate. In Short: How to configure a ManyToMany association with Hibernate when the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I have been using php-sdk to connect to facebook for a while and I never had any problems, but ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    recently i'm working on some project with arm but no OS in it. Now when i compile it, i must ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Which program code doesn't need preprocessing before being run? (a) Text (b) Script (c) Both Text ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 21, 2021 in Education by JackTerrance
0 votes
    So I have some code which copies files to 5 remote PCs on the network. I have a class which ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    Tested for Bash 5.0.2 According to the GNU Bash Reference Manual, Bash performs the expansion [of a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Tested for Bash 5.0.2 According to the GNU Bash Reference Manual, Bash performs the expansion [of a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
...