5

I have a java application I've written in eclipse. It works fine there.

It works fine run from a command line in the directory where I export it to. In that directory is another directory containing two jar files that I need for the application, and the manifest file has a Class-path option specifying them.

I want a way to use eclipse to generate the necessary file(s) to package this application to run on another machine. Is that possible?

If I choose "create executable jar file", it creates this huge file; it does unpack and repack the two libraries, which I know is one way to get their functionality included. I would actually prefer it if they were left as their own jars somehow, but I am not certain eclipse can do that. More annoying is the fact that the executable jar file option puts lots of files from my eclipse project into that jar file. I don't see an option to choose what gets included there, though I do see a place to enter inclusion and exclusion "rules' in the project properties. Do those apply here? Is there somewhere else I go to select what does and does not get included in the "executable jar"?

If I choose "create jar" (ins of "create executable jar"), I don't see where there's an option to include these two jar files anywhere. Perhaps there is no place to include them where they could be used.

If possible, I do not want to use Ant, I do not want to use Maven, I do not want to download another tool. It seems to me that Eclipse already has all this information and I suspect it can already do this without having to go and learn yet another "nifty" tool.

arcy
  • 12,845
  • 12
  • 58
  • 103
  • Please see my answer [here](http://stackoverflow.com/questions/6615634/eclipse-extract-package-the-required-libraries-into-the-same-runnable-jar/6615827#6615827), it is very easy, do not be afraid of Ant. :) – Garrett Hall Nov 02 '11 at 19:54
  • I didn't say I was afraid of it; I said I didn't want to use it unless I had to. According to other answers, I don't. And although I said I didn't want to download it, what I really don't want to do is start on another learning curve for something that seems within eclipse's capabilities. – arcy Nov 03 '11 at 08:22
  • Just follow aleroot's answer, generate an Ant script and all you have to do is delete a few lines of XML. There is nothing to learn or download. – Garrett Hall Nov 03 '11 at 12:49
  • "Nothing to learn or download"? So it does not matter WHICH lines of XML I delete? And perhaps I should run the script somehow after I generate it? So it sounds like there IS something to learn. I don't know how much, I don't want to start, that's why I didn't want to. And all this while there is an answer posted here that does not involve another tool, which I said I preferred. You don't bother to say why your solution is better, you just tell me to use it. No, thanks. – arcy Nov 03 '11 at 14:55
  • @rcook - please try to appreciate that folks are trying to help you here and maybe you could try to come across a bit less "incensed" at suggestions you may not like to hear. Thanks. – Kev Jan 11 '12 at 01:13

3 Answers3

7

Eclipse has its own Jar export wizard for generate a runnable jar packed with required library or with the required library in a folder aside the jar.

Going in File ---> Export then choose Java - Runnable Jar

export

You can then choose how pack the jar and how handling libraries :

Jar packing

You can also save the ant script for later modification or use ...

aleroot
  • 71,077
  • 30
  • 176
  • 213
2

You actually should use Ant or Maven for your task, I see no other option. Ant is already packed with eclipse, you only need to install a JDK, not only a JRE.

Ant is very easy to learn and you can find billions of examples in the internet. With ant you can do exactly what you want.

Maven is the more up-to-date way to build and package jars and do much more other stuff. Maven also is a good choice for you.

Stephan
  • 4,395
  • 3
  • 26
  • 49
0

I'll second a vote for Maven. Eclipse has a decent maven integration (m2eclipse). Then check out this answer for building the jar effectively using Maven2

Building a runnable jar with Maven 2

Community
  • 1
  • 1
dmcnelis
  • 2,913
  • 1
  • 19
  • 28
  • Well, if you'll read the question again, you'll see that I said I didn't want to do this. If you and other are going to insist that it is the only way, you might at least explain why. One answer appears to do this with eclipse alone; hopefully that will serve. – arcy Nov 03 '11 at 08:27