0

Realized a similar question was posted earlier but had no answers. Uuse both a manifest.mf and also pass jars using cp?

  1. What is the best way to define classpath in java batch environment? Can both Manifest.MF and cp argument via Command line be used or Do one override the other or Do one takes precedence over the other?

  2. If I am using JavaEE-API jar instead of the actual JMS* and XML* jars which are available on the server. Do I need to include each individual jar in the build.gradle as "runtime" ? for traceability on the actual dependencies? What would be the best practice?

  3. Taking Continuous integration into account, should the server side dependency jars be packaged along with the application jar, so that its a standalone app ?!

Thank you,

Community
  • 1
  • 1
ravikanth
  • 151
  • 1
  • 10
  • It appears -cp overrides manifest.mf. with an understanding that we dont use -jar option. Refer to comments in http://stackoverflow.com/questions/8843612/override-the-classpath-in-the-manifest-mf-of-a-jar?rq=1 – ravikanth Jun 22 '16 at 14:07
  • It appears not to bundle "provided" jars(Ex, javaee, was, jboss, etc.). Also for builds use api jar's when available instead of actual jars.. example javaee-api.jar instead of jms.jar. Also Refer to comments as well on, When to add a jar to server classpath versus application classpath... http://stackoverflow.com/questions/26371010/jar-dependency-application-server-classpath-vs-adding-it-to-the-application-wa?rq=1 – ravikanth Jun 22 '16 at 14:38

1 Answers1

0

What is the best way to define classpath in java batch environment ? Can both Manifest.MF and cp argument via Command line be used or Does one override the other or Does one takes precedence over the other ?

Nowadays, it's common to create an uber jarfile, one that includes all of its dependencies together, and then to create an executable jar, which leverages the manifest file.

To be clear, if you use the -cp command line option, you still need to specify the class to call containing your application entry point, i.e. the class containing public static void main(String[] args).

If I am using javaee-api jar instead of the actual jms* and xml* jars which are available on the server. Do I need to include each individual jar in the build.gradle as "runtime" ? for tracebility on the actual dependencies ? What would be the best practice ?

The better scope to use here is provided, since these libraries will be provided for you by the container.

Taking Continuous integration into account, should the server side dependency jars be packaged along with the application jar, so that its a standalone app ?!

This is a very common practice now, and it simplifies deployment because all dependencies are bundled together. This is the approach that the Dropwizard web service framework has taken, using Jetty as an embedded container.

ck1
  • 5,243
  • 1
  • 21
  • 25
  • 1. that still doesnt answer if we can use manifest and -cp both for classpath's or if there is a restriction. 2. I believe gradle does not have provided instead an equivalent new dependency would be compileonly. 3. Also, I have been reading that we can not run or use jar inside jar... what does that mean interms of bundling all the jars together ? – ravikanth Jun 22 '16 at 13:36