Unable to execute program using the jar option.

D

dan

Oddly I am unable to execute my jar directly (without getting an
exception); however, by specifying the class directly it runs just
fine.

If I had to guess.. it seems that it is related to my 2 system
properties .. it is behaving as if my classpath is being corrupted
when I use the -jar flag.

fails: (specifying the jar file to run)
%JAVA_HOME%\bin\java -Dframework.runtimeContext="DEV" -
Dframework.properties="H:\Java\Configuration\Extractor\properties
\framework.xml" -jar h:\Migration\migratorCode\cwsmigrator.jar /
mode:import /config:myconfig.xml

works: (specifying the class with main)
%JAVA_HOME%\bin\java
-Dframework.runtimeContext="DEV"
-Dframework.properties="H:\Java\Configuration\Extractor\properties
\framework.xml" package.MigrationDirector /mode:import /
config:myconfig.xml

Details:

Using: Sun Java 1.4.2
Exception: I believe the exact Exception is irrelevant to this issue
as I believe the real issue is the JVM is not
being passed the system properties; however, I will paste it here
anyways.
java.lang.NoClassDefFoundError: com/company/aid/config/
PropertyManagerException
at
com.company.cws.migrator.MigrationDirector.main(MigrationDirector.java:
42)
Exception in thread "main"

Classpath: Contains all needed jars (or it wouldn't work by specifying
just the main class) .. and it does have "." included in the path. The
path definately has the jar file that contains the class the exception
is complaining about .. this has been verifed and it would not work
the other way if this was not the case.

Jar file .. has the manifest file that determines the main class
(MigrationDirector); I don't think this is an issue since it is not
complaining about finding the MigrationDirector .. it complaining
about a class that can't instant
Have recompiled the jar file several time in case it was a fluke.

THANKS!
 
K

Knute Johnson

dan said:
Oddly I am unable to execute my jar directly (without getting an
exception); however, by specifying the class directly it runs just
fine.

If I had to guess.. it seems that it is related to my 2 system
properties .. it is behaving as if my classpath is being corrupted
when I use the -jar flag.

fails: (specifying the jar file to run)
%JAVA_HOME%\bin\java -Dframework.runtimeContext="DEV" -
Dframework.properties="H:\Java\Configuration\Extractor\properties
\framework.xml" -jar h:\Migration\migratorCode\cwsmigrator.jar /
mode:import /config:myconfig.xml

works: (specifying the class with main)
%JAVA_HOME%\bin\java
-Dframework.runtimeContext="DEV"
-Dframework.properties="H:\Java\Configuration\Extractor\properties
\framework.xml" package.MigrationDirector /mode:import /
config:myconfig.xml

Details:

Using: Sun Java 1.4.2
Exception: I believe the exact Exception is irrelevant to this issue
as I believe the real issue is the JVM is not
being passed the system properties; however, I will paste it here
anyways.
java.lang.NoClassDefFoundError: com/company/aid/config/
PropertyManagerException
at
com.company.cws.migrator.MigrationDirector.main(MigrationDirector.java:
42)
Exception in thread "main"

Classpath: Contains all needed jars (or it wouldn't work by specifying
just the main class) .. and it does have "." included in the path. The
path definately has the jar file that contains the class the exception
is complaining about .. this has been verifed and it would not work
the other way if this was not the case.

Jar file .. has the manifest file that determines the main class
(MigrationDirector); I don't think this is an issue since it is not
complaining about finding the MigrationDirector .. it complaining
about a class that can't instant
Have recompiled the jar file several time in case it was a fluke.

THANKS!

What is the name of the main class, package.MigrationDirector or
com.company.cws.migrator.MigrationDirector? Is the class
PropertyManagerException actually in one of the jar files? What is the
actual content of the manifest file?
 
L

Lew

When run with "-jar", the "java" command ignores any external classpath and
looks only in the JAR manifest for its class paths.
 
D

dan

When run with "-jar", the "java" command ignores any external classpath and
looks only in the JAR manifest for its class paths.

Thanks Lew, you hit the nail on the head. I guess there is more to a
jar than I had originally thought. For my project I guess I don't
need to create the executable jar; I'm not distributing a jar and I
have full control over the environment. I appreciate the quick and
thorough response.
 
L

Lew

dan said:
I appreciate the quick and thorough response.

No problem. It didn't take me very long googling around, given that I knew we
were dealing with "Java JAR classpath"s, to come up with the information. And
of course, all I did was quote the material I found; it's not like I needed to
be especially knowledgeable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top