Forum Stats

  • 3,838,748 Users
  • 2,262,397 Discussions
  • 7,900,749 Comments

Discussions

invocation api and wildcard in classpath

850193
850193 Member Posts: 2
edited Mar 25, 2011 4:52PM in Java Native Interface (JNI)
Hello,

I am sure this topic has been discussed before but I cannot find any thing close to this so I am posting here. Hopefully I will hear back in time.

I am creating a VM with the option "-Djava.class.path=/home/rrp/classes/*" (using java 1.6 libraries). I am getting a NoClassDefFoundError. The classes directory contains jar files and one of the jar file has this class in it. If I list the jar file in CLASSPATH as "/home/rrp/classes/my.jar" it works fine. Is this a bug? OR am I doing something wrong?

Thanks
Raj

Answers

  • 796440
    796440 Member Posts: 19,179 Gold Trophy
    edited Mar 24, 2011 5:16PM
    Do the following:
    echo /home/rrp/classes/*
    echo
    echo
    echo '/home/rrp/classes/*'
    Then make sure your command line looks like
    -Djava.class.path='/home/rrp/classes/*'
    with the quotes around the path so that the '*' doesn't get expanded by the shell.

    Also, why are you using -D instead of -cp? Does that even work?

    Edited by: jverd on Mar 24, 2011 2:16 PM
  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    jverd wrote:
    Also, why are you using -D instead of -cp? Does that even work?
    Wouldn't surprise me if that is the reason the expansion isn't working.
  • 796440
    796440 Member Posts: 19,179 Gold Trophy
    edited Mar 24, 2011 7:40PM
    nevermind, mis-read

    Edited by: jverd on Mar 24, 2011 4:40 PM
  • 796440
    796440 Member Posts: 19,179 Gold Trophy
    jschell wrote:
    jverd wrote:
    Also, why are you using -D instead of -cp? Does that even work?
    Wouldn't surprise me if that is the reason the expansion isn't working.
    Interesting. So even if -D is a valid substitute for -cp (which it may or may not be), it might be that -cp will expand the '*' into a proper colon-separated classpath and then set the java.class.path System Property to that expanded value, while specifying the property directly on the command line bypasses that expansion, leaving us with an unexpaded '*' as the (invalid) classpath. I hadn't thought of that.
  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    jverd wrote:
    jschell wrote:
    jverd wrote:
    Also, why are you using -D instead of -cp? Does that even work?
    Wouldn't surprise me if that is the reason the expansion isn't working.
    Interesting. So even if -D is a valid substitute for -cp (which it may or may not be), it might be that -cp will expand the '*' into a proper colon-separated classpath and then set the java.class.path System Property to that expanded value, while specifying the property directly on the command line bypasses that expansion, leaving us with an unexpaded '*' as the (invalid) classpath. I hadn't thought of that.
    Yes.
This discussion has been closed.