The Artima Developer Community
Sponsored Link

Java Answers Forum
Linking external jar while launching a jar problem

4 replies on 1 page. Most recent reply: Nov 1, 2005 11:58 PM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Alexander Serbul

Posts: 4
Nickname: alexserbul
Registered: Oct, 2005

Linking external jar while launching a jar problem Posted: Oct 31, 2005 1:59 AM
Reply to this message Reply
Advertisement
Good day!

I have a little test program:

import org.apache.log4j.Logger;

public class CMDClient {
static Logger log;
public static void main(String args[]) throws Exception {
log.info("test");
System.exit(1);
}
}

After I created a test.jar with only this class included and when I started it with java -jar test.jar it is error: java.lang.NoClassDefFoundError org/apache/log4j/Logger.

I tried to set before launching CLASSPATH=path_to_log4j_jar but it didn't help.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Linking external jar while launching a jar problem Posted: Oct 31, 2005 2:27 AM
Reply to this message Reply
> I tried to set before launching
> CLASSPATH=path_to_log4j_jar but it didn't help.

In Windows its:

set CLASSPATH=path_to_log4j_jar.jar

In *nix it would be:

export CLASSPATH=path_to_log4j_jar.jar

Alexander Serbul

Posts: 4
Nickname: alexserbul
Registered: Oct, 2005

Re: Linking external jar while launching a jar problem Posted: Oct 31, 2005 4:33 AM
Reply to this message Reply
This is my .bat file:

@echo off
set CLASSPATH=F:\CMD-CVS\projects\lib\log4j.jar
echo %CLASSPATH%
java -jar build\client-jars\cmd-client.jar

... and this is not working ;-(

It is interesting, that while I start this test program simply without packaging into jar, it works well.

Alexander Serbul

Posts: 4
Nickname: alexserbul
Registered: Oct, 2005

Re: Linking external jar while launching a jar problem Posted: Oct 31, 2005 4:51 AM
Reply to this message Reply
The problem was: it was needed to set Class-Path attribute in my MANIFEST.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Linking external jar while launching a jar problem Posted: Nov 1, 2005 11:58 PM
Reply to this message Reply
the set command often doesn't do what one would expect.
Therefore I allways include the classpath in the java command or in the manifest.

Flat View: This topic has 4 replies on 1 page
Topic: Arrays & Methods Previous Topic   Next Topic Topic:

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use