0

I have to create a jar file wherein i need to add external jar files in the classpath, properties files, in such away as to run it on any other machine.

sameer59
  • 97
  • 11

3 Answers3

1

You could either use manifest.mf to define external class path or use script that composes classpath and runs your application.

AlexR
  • 114,158
  • 16
  • 130
  • 208
1

I really recommend you to use a build tool such as Maven for these things:

http://maven.apache.org/

How can I create an executable JAR with dependencies using Maven?

Regards,

Boskop

Community
  • 1
  • 1
boskop
  • 609
  • 5
  • 23
  • 1
    This is my personal favorite answer - I use Maven for every project for some years now and it is really THE Java build tool for me. For creating executable JAR files with dependencies I prefer using the shade plugin, because it's really easy to use and works well. – Michael Schmeißer Apr 16 '12 at 07:44
1

You can make the jar in almost any IDE. I agree with Michael SchmeiBer, be a bit more specific please.

I use eclipse as my IDE (because you can both use it in windows and Ubuntu Linux) to make a jar (you can define the startup class in the jar).

I use different methods for starting up of different machines.

I use nsis to create a nice windows executable (.exe) You can include your own icon.

In nsis script you actually use the same command you would use in a batch command. nsis has some nice features, like search for a java jre.

For Linux and Mac I use a .sh file with this command.

dplante
  • 2,445
  • 3
  • 21
  • 27
michel.iamit
  • 5,788
  • 9
  • 55
  • 74