Solved

.jar File Can't Find Main Class - Newbie

Posted on 2009-06-29
5
662 Views
Last Modified: 2013-11-23
Hello All,
I will warn you up front that I do not know java and am learning it only to support some interfaces that were written by a previous co-worker, so I apologize in advance for my lack of knowledge.

To my knowledge, my co-worker used Eclipse when building these interfaces.  I do need to make some changes to them, but overall they have been running fine.  However, we recently received new workstations and now the .jar files won't run and produce an error saying that they can't find the Main Class.

I have ensured that the path on the new computers contains the path to the java folder but am not sure what else to look for.  After more investigation, it looks like the interface files only ever did run successfully on a handful of pc's, but I have no idea what my co-worker may have done to these to get them to work.  For the most part, my new pc has the same software as my previous one (which was able to run the interfaces).

I know that this is really open-ended, but what could the jar file be needing that is external to itself?  From my (albeit limited) understanding, the .jar file should 'stand alone'.  We can still run the .jar files on the 'old' computers and they work fine.  We are running them from a shared network drive, so the interfaces themselves have not changed, just the pc's.

Thanks.
Carmen
0
Comment
Question by:SysApps
[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
5 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 24736977
Java finds things using the classpath (not the PATH). There are various ways of making the JVM aware of what classpath you want it to use. Arguably the most simple and straightforward one is to specify it in the command line (usually "-classpath"). A jar file can also be specified as part of the class path as if it was a directory to search.
0
 

Author Comment

by:SysApps
ID: 24737429
How do I know what classpath I want/need it to use?  There is a ClassPath.class file within the .jar file.
Interface-zipfile.doc
0
 
LVL 16

Accepted Solution

by:
imladris earned 250 total points
ID: 24741351
The classpath normally specifies the directory in which the class files are found or, in the case of a jar, specifies the .jar file itself.

So, for instance, if the jar file is c:\system\time\punch.jar then you would add:

-classpath c:\system\time\punch.jar

as an argument to the java command that starts the program.
0
 
LVL 1

Expert Comment

by:sukalp
ID: 24744149
Either you could add that command to the command line or you could add it to the system wide Environment by ->
  For Vista,

1) Right Click on Computer in the Start Menu and then choose Properties.
2) Choose Advanced system settings from the list on the left.
3) Under the advanced tab, choose Environment variables.
4) Either add the CLASSPATH environment variable to the user variables or the system-wide variables as be your choice or if it already exists modify it to point to your files.
Click one the following options, for either a user or a system variable:
Click New to add a new variable name and value.

Click an existing variable, and then click Edit to change its name or value.
Click an existing variable, and then click Delete to remove it.

For XP,
Right-click My Computer, and then click Properties.
Click the Advanced tab.
Click Environment variables.

Click one the following options, for either a user or a system variable:
Click New to add a new variable name and value.

Click an existing variable, and then click Edit to change its name or value.
Click an existing variable, and then click Delete to remove it.

If this does not work, check your java command,
it should be java -jar <whatever> and also (if you are using one) if your jar manifest file is correct.


0
 

Author Closing Comment

by:SysApps
ID: 31597955
I tried all of the suggestions and it turned out to be something that we missed - there was an odbc missing, which others had supposedly checked for, but I guess you need to always double check yourself.

Thanks to all.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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 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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

622 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