Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Unable to execute program using the jar option.

Thread view: 
dan - 29 May 2007 17:39 GMT
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!
Knute Johnson - 29 May 2007 18:55 GMT
> Oddly I am unable to execute my jar directly (without getting an
> exception); however, by specifying the class directly it runs just
[quoted text clipped - 44 lines]
>
> 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?

Signature

Knute Johnson
email s/nospam/knute/

Lew - 29 May 2007 20:18 GMT
dan wrote:
>> Oddly I am unable to execute my jar directly (without getting an
>> exception); however, by specifying the class directly it runs just
[quoted text clipped - 3 lines]
>> properties .. it is behaving as if my classpath is being corrupted
>> when I use the -jar flag.

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

<http://java.sun.com/docs/books/tutorial/deployment/jar/run.html>:
> The -jar flag tells the interpreter that the application is packaged in the JAR file format.
> You can only specify one JAR file, which must contain all the application-specific code.

and <http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html>:
> The user class path is specified as ...
> The JAR archive specified by the -jar option, which overrides all other values.
> If this option is used, all user classes come from the specified archive.
...
> A JAR file usually contains a "manifest" -- a file which lists the contents of the JAR.
> The manifest can define a JAR-class-path, which further extends the class path
> (but only while loading classes from that JAR).

Signature

Lew

dan - 01 Jun 2007 03:52 GMT
> dan wrote:
> >> Oddly I am unable to execute my jar directly (without getting an
[quoted text clipped - 25 lines]
> --
> Lew

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.
Lew - 01 Jun 2007 15:00 GMT
> 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.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.