#maven jar file run

1 messages · Page 1 of 1 (latest)

pine elk
#

So i have my project
Which i can build an artifact and run it's jar file using command in cmd (i can't by just right click)

So recently i add maven with two dependencies for apache poi to deal with excel files
The problem is
The program run perfectly in IDE's terminal
But when i build artifact
Cmd just open and close and same time with no output
What is the solution ?
I searched and found the you have to change the execution command
To" java -cp filename.jar package.name.mainClassName
" From "java -jar file name"
-So what is the primary solution for this problem with maven.
-Also why normal jar file can't execute with just right click

hot grottoBOT
#

<@&987246452180930620> please have a look, thanks.

hot grottoBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

rustic crane
#

It's most likely due to the dependencies missing from your jar file.

#

You can add the dependencies to the classpath and then run the main class like

java -cp "/path/to/main.jar;/path/to/libs/*" org.togetherjava.Main
#

The * character indicates that it's a wildcard and it will add all files in that directory to the classpath.

#

Alternatively you could add them all individually.

#
java -cp "/files/main.jar;/files/lib1.jar;/files/lib2.jar" org.togetherjava.Main
#

Alternatively alternatively, you can create what we call a fat or uber or shadow jar that contains the main files for your application, as well as all of the dependencies it uses in to a single jar file.

#

@pine elk

pine elk
tiny barn
#

Build tools help with managing the building process of your project. Everything from creating a project, to managing the stuff your project needs, to configuring the lifecycle of a project (downloading dependencies, compiling, testing, running, packaging)