Solved

Packaging in Eclipse

Posted on 2008-06-11
6
368 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
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 116
object oriented programming comparison 5 77
oracle 11g 23 106
servlet example 11 49
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

840 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