Build executable jar

Please let me know how I can build an executable .jar out of my project.

Thanks!
dshrenikAsked:
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.

for_yanCommented:
Are you using some IDE ?
0
for_yanCommented:
0
dshrenikAuthor Commented:
I am using Eclipse.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

for_yanCommented:
You'll find in that link above even two ways - one is in the question itself - another is inthe answer
0
dshrenikAuthor Commented:
I get this error when I try to run thecreated .jar:
Failed to load Main-Class manifest attribute
0
for_yanCommented:
and this is even youtibe tutoarila
http://www.youtube.com/watch?v=Czmc2-hSBuk
0
for_yanCommented:
wellcopy this .jar to .zip - unzip it and check if you have manifest.mf file and if it syas waht is your main class
0
for_yanCommented:
If not, try to recreate it jar again
0
dshrenikAuthor Commented:
It has just this info:

Manifest-Version: 1.0
0
for_yanCommented:
So, it didn't create correctly; try again - check these links or waht youtube video
0
for_yanCommented:
It should be like that:

Manifest-Version: 1.0
Main-Class: JarExample

see:
http://www.astahost.com/info.php/Creating-Executable-Jar-Files_t12219.html
0
for_yanCommented:
Do you have your project running in Eclipse as Application, - do you have configure Run configuration ?
0
dshrenikAuthor Commented:
When I open Run-> Run Configurations,
It has the right project name and right main class.
0
for_yanCommented:
Try to recreate it - say you can do as in the video or as recommende in stackoverflow question
0
dshrenikAuthor Commented:
I did just as shown in the video!
Except for the fact that I'm using a different version of Eclipse - Galilieo.
0
for_yanCommented:
I just did it with one of my projects and got manifest.mf like that:

Manifest-Version: 1.0
Rsrc-Class-Path: ./
Class-Path: .
Rsrc-Main-Class: Outer
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

Open in new window

I think it is OK
I have Helios, but don't think it should be different
0
dshrenikAuthor Commented:
Now, it says "Cannot find the main class" when I try to run the jar.
0
for_yanCommented:
Did you go to Run As
select the project and the main class, then said Apply

Then you go to Export, selecte Runnable jar, then go to  Next  sleect configuration and select the file name and folder for the jar
0
for_yanCommented:
But if you don't have specification of Main class in your manifest it would scertalinly say so
0
dshrenikAuthor Commented:
Now I do have the specification.
It says:

Manifest-Version: 1.0
Main-Class: com.HealthMonitor.Monitor
0
for_yanCommented:
do you have such class in the appropriate folder ?

do yiou run it with

java -jar YourJarName.jar
0
dshrenikAuthor Commented:
Yes. It still says "Cannot find main class".
0
for_yanCommented:
Does it run in Ecliopse?
0
dshrenikAuthor Commented:
Yes!
0
dshrenikAuthor Commented:
Run As -> Java Application works perfectly.
0
for_yanCommented:
Try to do the same with some very simple project

Which java are you using on the comman line?
0
dshrenikAuthor Commented:
When I type "java -version", i get
1.6.0_20
0
for_yanCommented:
Try to create non-executable jar from your procject and make sure it runs
when you reference you main class directly on the command line
0
for_yanCommented:



in here
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219530

 I read:

Steps To Reproduce:
1. File > Export > Java/Runnable JAR File
2. Wizard Page "Runnable JAR File Specification" shows up
3. Enhancement: new checkbox "use Jar-in-Jar Classloader" appears

Do you have a checkbox  "use Jar-in-Jar Classloader"  in Runnable JAR File Specification screen ?

I do not have such box, but
my Eclipse by fdefault creates this jar-in-jar, yours does not create it, just
wrirtes Main-class. Still should work, but if you happen to have this
checkbox, maybe you want to use it





0

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
for_yanCommented:
What is the exact error message:

Does it look like this:

Could not find the main class: <something> Program will exit.

If so, what is <something> ?
0
dshrenikAuthor Commented:
I tried the steps you mentioned. Now, when I double click the .jar file, nothing happens.
0
for_yanCommented:
I normamly not double-click jar

I go to command libne and type there

java -jar YourClass.jar

does it workm this way?
0
for_yanCommented:
I meant

java -jar YourJar.jar
0
dshrenikAuthor Commented:
Thanks a ton!
0
for_yanCommented:
Great!
0
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
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.