• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Maven for sharing Jar  RSS feed

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please tell me how to place my jar file,in a sharing place so that others can see.

please indicate the exact command for this

ex: mvn.cmd --->?


Thanks
As
CRMK
 
Sheriff
Posts: 4562
286
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doing a "mvn clean install" will build your application artefact and deploy it into your local .m2 repository. If you want to share it with other people in your organisation then you can use a product called Nexus which acts as your own Maven Repository. Otherwise if you want to make it available to the world then you can use SonaType to deploy it to Maven Central.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:Doing a "mvn clean install" will build your application artefact and deploy it into your local .m2 repository. If you want to share it with other people in your organisation then you can use a product called Nexus which acts as your own Maven Repository. Otherwise if you want to make it available to the world then you can use SonaType to deploy it to Maven Central.



Hi
Thanks.However,on a methodical way,I was able to create a jar file for an application prg in java using the mvn.cmd command.
But it is empty one with the name 1.0SNAPSHOT.jar with maven-archiver folder ofcourse .Please let me know the correct command to make
maven create a fully exexcutable jar file

The first method was as below:

mvn.cmd archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
The next usage is
mvn.cmd clean jar:jar

Though the error is minor i the fixing for the creation of jar may be helpful contexually
As
CRMK
The following text is self explanatory to what is required as above (viz Executable jar)



 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Any alternative method to include the manifest.txt details of the jar ile in either pom.xml file(root dir) or sub directory of the same in another pom.xml.This is just to make the jar executable
Thanks
As
CRMK
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please ref my Build which clears succesfully.But my main request is why the jar file created by maven is always emty or rather not opening
Please indicate where to give a correction in the pom.xml (unjar:xvf name.jar--like) that includes the manifest.txt to the jar file to make it executable.
Thanks
As
CRMK



 
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be kind enough not to repeat long quotes when posting. The longer I have to scroll past them, the less it is likely I'll bother to do so.

Webapps are not placed in "executable jars". In Java parlance, an "executable jar" is something that you can run by typing a console command such as "java -jar my.jar". A webapp must be in the form of a WAR or EAR. The exception to this would be if you were creating a Spring Boot jar, which contains an executable webserver as well as the webapp in it, but I don't think that this is what you're asking about, because that's a fairly advanced topic and people who do that usually already have experience in creating WARs.

To get Maven to produce a WAR, you must configure the maven WAR plugin into your Maven POM and have your source directories located in the places that Maven expects them to be. Maven will then compile code, copy resources, and build an exploded WAR under the project's "target" directory. Following that, it will ZIP up the exploded WAR into an actual WAR file (assuming you're using standard build options). The Maven install command then proceeds to copy this WAR file, along with Maven metadata to the .m2/repository directory.

Thus, the first thing you need to do is ensure that a proper WAR is being built in your target directory. You also need to be sure that the .m2 repository has enough free disk space and that it's writable by you (since you own it, it normally is).

It's possible to create a WAR and post it to a public directory where other users can access it, but that's an entirely different level of complexity.

 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Please be kind enough not to repeat long quotes when posting. The longer I have to scroll past them, the less it is likely I'll bother to do so.

Webapps are not placed in "executable jars". In Java parlance, an "executable jar" is something that you can run by typing a console command such as "java -jar my.jar". A webapp must be in the form of a WAR or EAR. The exception to this would be if you were creating a Spring Boot jar, which contains an executable webserver as well as the webapp in it, but I don't think that this is what you're asking about, because that's a fairly advanced topic and people who do that usually already have experience in creating WARs.

To get Maven to produce a WAR, you must configure the maven WAR plugin into your Maven POM and have your source directories located in the places that Maven expects them to be. Maven will then compile code, copy resources, and build an exploded WAR under the project's "target" directory. Following that, it will ZIP up the exploded WAR into an actual WAR file (assuming you're using standard build options). The Maven install command then proceeds to copy this WAR file, along with Maven metadata to the .m2/repository directory.

Thus, the first thing you need to do is ensure that a proper WAR is being built in your target directory. You also need to be sure that the .m2 repository has enough free disk space and that it's writable by you (since you own it, it normally is).

It's possible to create a WAR and post it to a public directory where other users can access it, but that's an entirely different level of complexity.





Hi

Thanks .However my try has been quite unsuccesful,though the maven creates a jar in the target folder is only a jar file(emty) unable to execute on double click.
And war creation is totally very combursome .Underthese circumstances why not you suply me a fresh pom.xml which is more effective for the task..Iam unable to
configure my pom file with that of maven-jar-plugimn-2.6 that i downladed.
Hopefully to receive i scintilating guidance from modest self
Thanks
AS
CRMK
 
Tim Holloway
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A POM is a custom file that contains specifics about your project. Even if we were into doing other people's homework here, my POMs would be useless to you.

As I said earlier, however, a webapp is not a JAR, it's a WAR. You should be using the following goals instead of the jar:jar goal:

Or, more simply:
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:A POM is a custom file that contains specifics about your project. Even if we were into doing other people's homework here, my POMs would be useless to you.

As I said earlier, however, a webapp is not a JAR, it's a WAR. You should be using the following goals instead of the jar:jar goal:

Or, more simply:



Hi
Thanks But still,the clarity is not understood.Would be more meaningfull if the difference between goal and the pom elements .since the goal should be put in mvn.cmd command whichexectes only after a POM is existing in the root directory.Or is there simple way of making POM ,as for example by defining groupId artifactId,version,packaging which generates a POM.by use archetype:generate command.
Also why the jar file thus created is always kept empty even when it is successfully built by maven .
As
CRMK
 
Tim Holloway
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All Maven projects must have a POM file. Maven is a declarative-based build system where the declarations are elements of the POM. A POM can produce one and only one final artefact. Depending on the declarations contained within the POM, this artefact may be a JAR, a WAR, an EAR or in some cases, even a non-Java product such as a Red Hat RPM package.

Maven operates to achieve one or more goals. For example, the goal named "clean" deletes the project's "target" directory and its subsidiaries. The goal named "compile" compiles source code. Some goals implicitly trigger pre-requisite goals. For example, the "package" goal when run against a POM defining a WAR product will run the "compile" and "war:war" goals. You can also create plugin enhancements to Maven that can be triggered to act when certain goals are invoked. These plugins are called "mojos".

There are a number of public archetypes that can build prototoype POMs for web applications, including enhancements such as Hibernate. But a very basic WAR POM can be constructed using the sample command on this webpage:

https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/webapp.html

For detailed information on Maven, there are the documentation on maven.apache.org, although there are also several books on Maven.

I will repeat for third time: A webapp is a WAR not a JAR. There is nothing to do with JARs in this process.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:All Maven projects must have a POM file. Maven is a declarative-based build system where the declarations are elements of the POM. A POM can produce one and only one final artefact. Depending on the declarations contained within the POM, this artefact may be a JAR, a WAR, an EAR or in some cases, even a non-Java product such as a Red Hat RPM package.

Maven operates to achieve one or more goals. For example, the goal named "clean" deletes the project's "target" directory and its subsidiaries. The goal named "compile" compiles source code. Some goals implicitly trigger pre-requisite goals. For example, the "package" goal when run against a POM defining a WAR product will run the "compile" and "war:war" goals. You can also create plugin enhancements to Maven that can be triggered to act when certain goals are invoked. These plugins are called "mojos".

There are a number of public archetypes that can build prototoype POMs for web applications, including enhancements such as Hibernate. But a very basic WAR POM can be constructed using the sample command on this webpage:

https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/webapp.html

For detailed information on Maven, there are the documentation on maven.apache.org, although there are also several books on Maven.

I will repeat for third time: A webapp is a WAR not a JAR. There is nothing to do with JARs in this process.



Hi
Thanks much for your nice differenciation between war and jar especially so during mavens venture.
Accordingly i almost tried all means to make my maven produce jar to include my webapplication along with the classes and the manifest details.
with invain,there is now a few hopes left to activate my pom.xml by correcting here and there in order to make maven help me.
Please substantiate my pom in-lief of the fact that i was able to write this after so much of hatch-patch and inclusion task.
struggling with maven eversince you replied last.



As
CRMK









 
Tim Holloway
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO, you are not building a [b]JAR, you're building a WAR .[/b]

The top of your POM (before the <build>) should resemble this:

 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:NO, you are not building a [b]JAR, you're building a WAR .[/b]

The top of your POM (before the <build>) should resemble this:




Hi
my sincere thanks for your valuable suggestion.that resulted ok but
for the tantalizing behaviour on use of war and jar,ie.if I put the word war
and compile ,I get a failure report while usge of jar was successfull as under .However jar so
produced is as usual non executable,inspite of the fact three special additional properties were included for the project by me
as webxml attribute but still invain in its enablence. But on the whole as you said already, i feel that war is rather
very combursome and hard .you may please have a glimpse especially for the pom of the follwing and
if possible do needfull correction.(as for example you may include the relevent webapp attributes to make it activate the war/jar
I also tried the same by writing lke the folowing but not so ok hence resulted in failure.)

<web-app>
url-pattern='servlet',servlet name ='invoker'
</web-app>
.

Atleast I am sure you would now be able to say authenticaly as to why is the jar always kept empty.What and where I should should add to
make it otherwise filledwith classes.

Thanks
As
CRMK


 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Comal Rajagopalaratnam Muthukumar wrote:

Tim Holloway wrote:NO, you are not building a [b]JAR, you're building a WAR .[/b]

The top of your POM (before the <build>) should resemble this:







Hi
my sincere thanks for your valuable suggestion.that resulted ok but
for the tantalizing behaviour on use of war and jar,ie.if I put the word war
and compile ,I get a failure report while usge of jar was successfull as under .However jar so
produced is as usual non executable,inspite of the fact three special additional properties were included for the project by me
as webxml attribute but still invain in its enablence. But on the whole as you said already, i feel that war is rather
very combursome and hard .you may please have a glimpse especially for the pom of the follwing and
if possible do needfull correction.(as for example you may include the relevent webapp attributes to make it activate the war/jar
I also tried the same by writing lke the folowing but not so ok hence resulted in failure.)

<web-app>
url-pattern='servlet',servlet name ='invoker'
</web-app>
.

Atleast I am sure you would now be able to say authenticaly as to why is the jar always kept empty.What and where I should should add to
make it otherwise filledwith classes.

Thanks
As
CRMK




Hi
The maven tool seems to help with a thrilling climax for those who are consistent .But for me it is the otherway .neither jar nor war
satisfies however way i tried.so why not render help before it is late.
Thanks
As

CRMK




 
Tim Holloway
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, but what you want and what J2EE demands are two different things. Software isn't something where you can just throw anything you desire in and it gets done and no amount of copying and pasting entire messages will make it otherwise.

J2EE web applications require a WAR. Building a JAR will not work. At all. Ever. As long as you insist that you must build a JAR, no one can help you.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:I'm sorry, but what you want and what J2EE demands are two different things. Software isn't something where you can just throw anything you desire in and it gets done and no amount of copying and pasting entire messages will make it otherwise.

J2EE web applications require a WAR. Building a JAR will not work. At all. Ever. As long as you insist that you must build a JAR, no one can help you.


Hi
While your response seems to exhibit the main essentials,still i have this to get clarified ie have i to use j2ee also for building the war files & if so what should be POM file look like for making maven oblige .All opensource in general goes explainingabout maven.xml,build.xml,applicatin.xml etc I am yet to see any POM.xml for this elegant task. Atleast a model is shown that may suffice.Thanks
As
CRMK
 
Bartender
Posts: 9492
184
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comal, I suggest you reread all Tim's replies in this topic, read the Maven POM reference, and read online about how to build Java web applications.

You're repeating questions, and we're repeating answers.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Comal, I suggest you reread all Tim's replies in this topic, read the Maven POM reference, and read online about how to build Java web applications.

You're repeating questions, and we're repeating answers.



Hi
Indeed I am perplaxed to know the value of revisiting/re-reading since the following results
are self explanatory .I not only re-read the whole lot of the above tutorship/guidamnce but also finally
comprehended the organisation-structure for a forum especially and accordingly put all the relevancies
given above and created the pom.xml .During this endeavour I am able to know the importance of project descriptor that is the actual key requirement for the glorious creation

Thanks a lot

As
CRMK



 
Stephan van Hulst
Bartender
Posts: 9492
184
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad you figured it out
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I'm glad you figured it out



Hi
Now that i have built a war file successfully,how do i deploy . have i to make jsp file and jnlp file.what is the procedure for building such files any extra software is needed other than maven
Thanks
As
CRMK
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!