![]() |
can't find in classpath, but only when running from the jar file
I'm trying to run a Java class in a jar file. The jar file contains this class:
com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class The manifest looks like this (not indented). Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.4 Created-By: 1.7.0_03-b04 (Oracle Corporation) Main-Class: com.exacttarget.wsdl.partnerapi.PartnerAPIStub All the main class does is print "hello world". It works (prints "Hello World") if I do this in the classes directory... java com.exacttarget.wsdl.partnerapi.PartnerAPIStub This same class is definitely in the jar file as demonstrated by this command... bash-4.1$ jar tf PartnerAPI-test-client.jar |grep Stub.class com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class bash-4.1$ but when I try to run the jar, with the environment exactly as it was when I ran the class separately, using this command... java -jar PartnerAPI-test-client.jar I get this error output... Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub Obviously I'm missing something. Any help would very much be appreciated. |
Re: can't find in classpath, but only when running from the jar file
On 10/15/2012 10:56 AM, Stryder wrote:
> I'm trying to run a Java class in a jar file. The jar file contains this class: > > com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class > > The manifest looks like this (not indented). > > Manifest-Version: 1.0 > Ant-Version: Apache Ant 1.8.4 > Created-By: 1.7.0_03-b04 (Oracle Corporation) > Main-Class: com.exacttarget.wsdl.partnerapi.PartnerAPIStub > > All the main class does is print "hello world". It works (prints "Hello World") if I do this in the classes directory... > > java com.exacttarget.wsdl.partnerapi.PartnerAPIStub > > This same class is definitely in the jar file as demonstrated by this command... > > bash-4.1$ jar tf PartnerAPI-test-client.jar |grep Stub.class > com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class > bash-4.1$ > > but when I try to run the jar, with the environment exactly as it was when I ran the class separately, using this command... > > java -jar PartnerAPI-test-client.jar > > I get this error output... > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/axis2/client/Stub > > Obviously I'm missing something. Any help would very much be appreciated. > I think you're missing a Class-Path attribute. Class-Path: The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path. |
Re: can't find in classpath, but only when running from the jar file
On 10/15/2012 11:22 AM, Jeff Higgins wrote:
> On 10/15/2012 10:56 AM, Stryder wrote: >> I'm trying to run a Java class in a jar file. The jar file contains >> this class: >> >> com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class >> >> The manifest looks like this (not indented). >> >> Manifest-Version: 1.0 >> Ant-Version: Apache Ant 1.8.4 >> Created-By: 1.7.0_03-b04 (Oracle Corporation) >> Main-Class: com.exacttarget.wsdl.partnerapi.PartnerAPIStub >> >> All the main class does is print "hello world". It works (prints >> "Hello World") if I do this in the classes directory... >> >> java com.exacttarget.wsdl.partnerapi.PartnerAPIStub >> >> This same class is definitely in the jar file as demonstrated by this >> command... >> >> bash-4.1$ jar tf PartnerAPI-test-client.jar |grep Stub.class >> com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class >> bash-4.1$ >> >> but when I try to run the jar, with the environment exactly as it was >> when I ran the class separately, using this command... >> >> java -jar PartnerAPI-test-client.jar >> >> I get this error output... >> >> Exception in thread "main" java.lang.NoClassDefFoundError: >> org/apache/axis2/client/Stub >> >> Obviously I'm missing something. Any help would very much be appreciated. >> > I think you're missing a Class-Path attribute. > Class-Path: The value of this attribute specifies the relative URLs of > the extensions or libraries that this application or extension needs. > URLs are separated by one or more spaces. The application or extension > class loader uses the value of this attribute to construct its internal > search path. <http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html> |
Re: can't find in classpath, but only when running from the jar file
On 10/15/2012 11:22 AM, Jeff Higgins wrote:
> On 10/15/2012 10:56 AM, Stryder wrote: >> I'm trying to run a Java class in a jar file. The jar file contains >> this class: >> >> com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class >> >> The manifest looks like this (not indented). >> >> Manifest-Version: 1.0 >> Ant-Version: Apache Ant 1.8.4 >> Created-By: 1.7.0_03-b04 (Oracle Corporation) >> Main-Class: com.exacttarget.wsdl.partnerapi.PartnerAPIStub >> >> All the main class does is print "hello world". It works (prints >> "Hello World") if I do this in the classes directory... >> >> java com.exacttarget.wsdl.partnerapi.PartnerAPIStub >> >> This same class is definitely in the jar file as demonstrated by this >> command... >> >> bash-4.1$ jar tf PartnerAPI-test-client.jar |grep Stub.class >> com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class >> bash-4.1$ >> >> but when I try to run the jar, with the environment exactly as it was >> when I ran the class separately, using this command... >> >> java -jar PartnerAPI-test-client.jar or a classpath option java -jar -cp pathtomyaxis2clientjar PartnerAPI-test-client.jar >> >> I get this error output... >> >> Exception in thread "main" java.lang.NoClassDefFoundError: >> org/apache/axis2/client/Stub >> >> Obviously I'm missing something. Any help would very much be appreciated. >> > I think you're missing a Class-Path attribute. > Class-Path: The value of this attribute specifies the relative URLs of > the extensions or libraries that this application or extension needs. > URLs are separated by one or more spaces. The application or extension > class loader uses the value of this attribute to construct its internal > search path. |
Re: can't find in classpath, but only when running from the jar file
On 15/10/12 16:51, Jeff Higgins wrote:
> or a classpath option > java -jar -cp pathtomyaxis2clientjar PartnerAPI-test-client.jar > That won't work. The -cp option is ignored with -jar. If you use -jar you can only specify a classpath in the Class-Path: directive in the manifest, as explained in your previous posts. -- Nigel Wade |
Re: can't find in classpath, but only when running from the jar file
Jeff Higgins wrote:
> or a classpath option > java -jar -cp pathtomyaxis2clientjar PartnerAPI-test-client.jar Java will ignore the classpath option in this command. -- Lew |
Re: can't find in classpath, but only when running from the jar file
On 10/15/2012 11:51 AM, Jeff Higgins wrote:
> On 10/15/2012 11:22 AM, Jeff Higgins wrote: >> On 10/15/2012 10:56 AM, Stryder wrote: >>> but when I try to run the jar, with the environment exactly as it was >>> when I ran the class separately, using this command... >>> >>> java -jar PartnerAPI-test-client.jar > > or a classpath option > java -jar -cp pathtomyaxis2clientjar PartnerAPI-test-client.jar > I've supplied misinformation here. Quoting from the java - The Java Application Launcher manual <http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/java.html#options> -jar [snip] "When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored. " [snip] Thanks to Nigel and Lew for catching this.:) |
Re: can't find in classpath, but only when running from the jar file
On Mon, 15 Oct 2012 07:56:44 -0700 (PDT), Stryder
<stryder100@gmail.com> wrote, quoted or indirectly quoted someone who said : > >Obviously I'm missing something. Any help would very much be appreciated. see http://mindprod.com/jgloss/jar.html http://mindprod.com/jgloss/jarexe.html Jars ignore the SET=classpath. You need to put a classpath inside the jar with a Class-Path attribute in the manifest. -- Roedy Green Canadian Mind Products http://mindprod.com The iPhone 5 is a low end Rolex. |
Re: can't find in classpath, but only when running from the jar file
On 10/15/2012 10:56 AM, Stryder wrote:
> I'm trying to run a Java class in a jar file. The jar file contains this class: > > com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class > > The manifest looks like this (not indented). > > Manifest-Version: 1.0 > Ant-Version: Apache Ant 1.8.4 > Created-By: 1.7.0_03-b04 (Oracle Corporation) > Main-Class: com.exacttarget.wsdl.partnerapi.PartnerAPIStub > > All the main class does is print "hello world". It works (prints "Hello World") if I do this in the classes directory... > > java com.exacttarget.wsdl.partnerapi.PartnerAPIStub > > This same class is definitely in the jar file as demonstrated by this command... > > bash-4.1$ jar tf PartnerAPI-test-client.jar |grep Stub.class > com/exacttarget/wsdl/partnerapi/PartnerAPIStub.class > bash-4.1$ > > but when I try to run the jar, with the environment exactly as it was when I ran the class separately, using this command... > > java -jar PartnerAPI-test-client.jar > > I get this error output... > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/axis2/client/Stub > > Obviously I'm missing something. Any help would very much be appreciated. Other have already told you about the classpath. But try look at the message: java.lang.NoClassDefFoundError org/apache/axis2/client/Stub It actually clearly states that it can not find a class that is part of Axis2. The solution follow easily from that analysis. If you plan on programming in Java for the next 20 years, then you will see hundreds or thousands of error messages - you need to learn to use the information provided to resolve problems. Arne |
| All times are GMT. The time now is 08:38 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.