?
Solved

Packaging in Eclipse

Posted on 2008-06-11
6
Medium Priority
?
374 Views
Last Modified: 2013-12-15
This should be incredibly easy, and I guarantee it's something simple that I "should know," and just remain ignorant of.

First off, I'm not a java developer. My company does not develop in java. However, they recently thought that it would be a smart idea to purchase a program that does something that we want to do, and it was written in java. The guy came, set up eclipse on my machine, gave me the files, set everything up so I click "run dialog", and throw in a couple command line arguments into there, and everything runs just fine, then he left. I guess he assumed I knew what to do.

After researching / reading around, I have concluded that I have zero idea what I'm doing.

So, I have code that runs fine in eclipse. I'm not in Kansas, or my cozy little VS anymore, and there is no effin "compile" button that spits out a wonderful .exe.

I have tried "Exporting" the project by using file->export, and then use the command of Java -jar jarname.jar, but when it does that, it says that it can't find a class in one of the jars that is referenced in the project.

It works. I've seen it work. I can use it if I go into eclipse and run it. I just need to be able to hit it as a command line execution. What am I missing / not doing?

Thanks
--Xen
0
Comment
Question by:darkxenn
  • 2
  • 2
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
mbodewes earned 1000 total points
ID: 21764851
Basically you need to set up the classpath to point to the referenced libraries as well as the generated .jar file. But you might be better off packaging it all again into a .exe, which you seem to be more familiar with. Use jsmooth (open source0 or another packager to do that. You will have multiple options to included the referenced libraries.

Another way is to use java -cp "<full path to all .jar files separated by ;>" <the class containing the main excluding .class including package names separated by dots>. Most of the time I find -jar more difficult than this option, where the jar containing the main class is just part of the general classpath.

So something like java -cp "lib/main.jar;lib/log4j.jar" com.somecompany.main.Main


0
 
LVL 92

Expert Comment

by:objects
ID: 21764956
when your exporting your project as a jar there is an option to specify the main class. Specify the class name there and you should be right

0
 
LVL 9

Expert Comment

by:mbodewes
ID: 21765174
"I have tried "Exporting" the project by using file->export, and then use the command of Java -jar jarname.jar, but when it does that, it says that it can't find a class in /one of the jars/ that is referenced in the project."

Objects, if that was the main class, I suppose you would be right, but I wonder if this is the case. After reading the question I figured out it probably isn't, but maybe the author can explain further.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:darkxenn
ID: 21769436
"when your exporting your project as a jar there is an option to specify the main class. Specify the class name there and you should be right"

I already did that. The problem that I'm having is the jars included in the project. I'm gonna try out jsmooth here, and see how that goes.
0
 
LVL 1

Author Closing Comment

by:darkxenn
ID: 31466386
Thanks so much. Jsmooth was easy to deal with, and I got everything settled in no time.
0
 
LVL 92

Expert Comment

by:objects
ID: 21774293
Thats more likely to be a problem with where the jars are placed. Executable jars can access external jars just fine.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question