Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19356

Re: can't find in classpath, but only when running from the jar file

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: can't find in classpath, but only when running from the jar file
Date 2012-10-15 11:22 -0400
Organization A noiseless patient Spider
Message-ID <k5h9b5$2sa$1@dont-email.me> (permalink)
References <4a7b7c26-806b-4a3d-8fed-f56e35ba8d76@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

can't find in classpath, but only when running from the jar file Stryder <stryder100@gmail.com> - 2012-10-15 07:56 -0700
  Re: can't find in classpath, but only when running from the jar file Jeff Higgins <jeff@invalid.invalid> - 2012-10-15 11:22 -0400
    Re: can't find in classpath, but only when running from the jar file Jeff Higgins <jeff@invalid.invalid> - 2012-10-15 11:31 -0400
    Re: can't find in classpath, but only when running from the jar file Jeff Higgins <jeff@invalid.invalid> - 2012-10-15 11:51 -0400
      Re: can't find in classpath, but only when running from the jar file Nigel Wade <nmw@ion.le.ac.uk> - 2012-10-15 17:04 +0100
      Re: can't find in classpath, but only when running from the jar file Lew <lewbloch@gmail.com> - 2012-10-15 09:16 -0700
      Re: can't find in classpath, but only when running from the jar file Jeff Higgins <jeff@invalid.invalid> - 2012-10-15 13:00 -0400
  Re: can't find in classpath, but only when running from the jar file Roedy Green <see_website@mindprod.com.invalid> - 2012-10-15 19:43 -0700
  Re: can't find in classpath, but only when running from the jar file Arne Vajhoej <arne@vajhoej.dk> - 2012-10-17 11:52 -0400

csiph-web