java execs

Is there a way to bind all the classes built for an application into one executable?
Currently I have to have all the classes in the working/running directory.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could make a 'one jar' installation. Export in Eclipse will do that for you
You can use either Eclipse or Netbeans - they both have facilty t create executable .jar
this is how you craete Exceutabl Jar in Eclipse
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

this is even simpler to do in Netbeans:
see here descriprtion:

right-click your project,
"set main project",
select your project,
"PROJECTNAME Properties",
set your main class,
"Add JAR/Folder",
select your wanted libs,
do a CLEAN build,
enter the build-path,
enter /dist and be amazed --> DONE!
The last i looked, Netbeans can't do a One Jar export
This is pretty simple explanation of dio-it-yourself method
if you want to be independent of any IDE indpendent of any IDE,:

create MANIFEST.MF file with this content:

Class-path: third-party.jar blort.jar foo.jar

then run in your top-level class folder

jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2 ... third-party.jar blort.jar foo.jar ...

it will put  your classes from the default package and then process folders  top_package1 top_package2 recursively and put MANIFEST.MF into meta-inf folder (it will create meta-inf folder within the jar  itself)

Then, you can run AppMain like this:

java -jar app.jar
jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2 ... third-party.jar blort.jar foo.jar ...

Open in new window

That won't work. You can't nest jars
Yes, it is true, you should not jar the thord-party jars together:

jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2

you need to mention the put third party jars inMANIFEST and then put them  in the same folder as app.jar

and then you can  run it

java -jar app.jar

I tried it condensing there together thinking thatmaybe newer java works with it,
and it worked for me, but that happened because actuallt another copy of jar was present in the same folder

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Not quite sure why you accepted that answer. The instructions given, while correct in themselves, don't fulfill your requirement
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.