Solved

Packaging in Eclipse

Posted on 2008-06-11
6
362 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 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
"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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:darkxenn
Comment Utility
"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
Comment Utility
Thanks so much. Jsmooth was easy to deal with, and I got everything settled in no time.
0
 
LVL 92

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now