[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Packaging in Eclipse

Posted on 2008-06-11
6
Medium Priority
?
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

650 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