• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Maven Project in NetBeans 8.1

 
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've developed a Java Application by mean a Maven Project with NetBeans 8.1.
This application run as it's expected on NetBeans environment, using "Run project".
But now, I want to run the application outside NetBeans ,(in production).
By mean "Clean and Build", I get the jar in the maven local repository. But when I try to run this jar, I get:
"no main manifest attribute, in DerquiSystemsManagerFrontEnd-1.0-SNAPSHOT.jar"

How can I get a runnable jar from a Maven Project in NetBeans?
(I do not know much about Maven.)

Thank you, in advance.
 
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the the <configuration><archive><manifestEntries> tags for the maven-jar-plugin to add the required manifest entries to your Jar's manifest.

https://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you don't need <manifestEntries>, the maven archiver has a special element for that. So you could use this for your maven-jar-plugin configuration:
 
Adrian Cordoba
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Actually, you don't need <manifestEntries>, the maven archiver has a special element for that. So you could use this for your maven-jar-plugin configuration:



How can I do that with NetBeans?
I tried it, but I can't modify effective POM in NetBeans.
I'll appreciate details.

Thank you, very much.
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't modify the effective POM. You should modify the real POM. If you overwrite the configuration section of the related plugin, it will also appear in the effective POM.
 
Adrian Cordoba
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:You shouldn't modify the effective POM. You should modify the real POM. If you overwrite the configuration section of the related plugin, it will also appear in the effective POM.


You are right, Stephan. Thank you very much.
Now, I can run the application with "java -jar ....". But the jar has no dependencies.
Can you help me, in order to include dependencies in the jar?

Thank you, once again.
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

If you have any other queries regarding the manifest, check out the link I posted earlier, there is a lot of useful documentation there.
 
Adrian Cordoba
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Try:

If you have any other queries regarding the manifest, check out the link I posted earlier, there is a lot of useful documentation there.



Thank you, but <addClasspath>true</addClasspath> didn't work.
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless. Please tell us what you've done, what error message you get, and show us the content of the generated manifest. You see can see the manifest by opening the jar with an unzipper.
 
Adrian Cordoba
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:ItDoesntWorkIsUseless. Please tell us what you've done, what error message you get, and show us the content of the generated manifest. You see can see the manifest by opening the jar with an unzipper.


I beg your pardon.

First, I added the following snippet to the POM (by mean NetBeans):



Then, I "Clean and Build" (NetBeans) the project in order to get the jar.
This is the MANIFEST.MF inside the jar:



When I run the application by mean "java -jar .... " I get the following exception:



Note: The class ar.com.adriancordoba.app.commonlibraries.mavenlibrarytest.Person is in MavenLibraryTest-1.0-SNAPSHOT.jar.
This happens because MavenLibraryTest-1.0-SNAPSHOT.jar is not included inside the application's jar.

Please, can you tell me a good tutorial for learn Maven? (If shorter, the better.)
Maybe I can solve the problem by myself.

Thank you again.
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Adrian Cordoba wrote:This happens because MavenLibraryTest-1.0-SNAPSHOT.jar is not included inside the application's jar.


No, jars shouldn't ever be inside each other. In this case, your library jar should be in the same directory as your application jar. If you want your library to be in some other location, you should use <manifest><classpathPrefix> to specify the path that comes before all your classpath entries. I usually have ../lib/ as I distribute my application in MyApplication/bin and the referenced libraries in MyApplication/lib.

I don't have a quick tutorial. You can check out the Maven POM Reference, and work from there. For deploying applications, check out the Oracle tutorial on deployment.
 
Adrian Cordoba
Greenhorn
Posts: 26
Oracle Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:

Adrian Cordoba wrote:This happens because MavenLibraryTest-1.0-SNAPSHOT.jar is not included inside the application's jar.


No, jars shouldn't ever be inside each other. In this case, your library jar should be in the same directory as your application jar. If you want your library to be in some other location, you should use <manifest><classpathPrefix> to specify the path that comes before all your classpath entries. I usually have ../lib/ as I distribute my application in MyApplication/bin and the referenced libraries in MyApplication/lib.

I don't have a quick tutorial. You can check out the Maven POM Reference, and work from there. For deploying applications, check out the Oracle tutorial on deployment.



Thank you, very, very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!