• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 695
  • Last Modified:

.jar File Can't Find Main Class - Newbie

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
SysApps
Asked:
SysApps
  • 2
  • 2
1 Solution
 
imladrisCommented:
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
 
SysAppsAuthor Commented:
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
 
imladrisCommented:
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
 
sukalpCommented:
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
 
SysAppsAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now