Results 1 to 6 of 6

Thread: Classpath

  1. #1
    jojo is offline Member
    Join Date
    Dec 2009
    Posts
    36
    Rep Power
    0

    Default Classpath

    Hello,

    i'm trying todo the following:
    i have a jar file, this is what i do run first.
    Then i have a class that i want to run, which has to access a class in the jar file
    Why? I'm learning reflection.

    Note:
    I'm my folder i have this:
    jars/file.jar which is the jar file i run first
    Test.class - which calls the class.forName(classname); to acces the class in the jar file.

    This is the following i have:

    Java Code:
    @echo off
    C:> java "-classpath C:\Documents and Settings\xxx\Bureaublad\xxx\jars\file.jar"
    
    java Test
    
    echo Shutdown...DONE
    pauze
    but doesn't work. ANy idfeas???


    Thanks in advance!

  2. #2
    Turtle is offline Member
    Join Date
    Nov 2007
    Location
    New Zealand
    Posts
    36
    Rep Power
    0

    Default

    If you want to run files.jar then this command will run it:
    java -jar file.jar
    or
    java -jar jars/file.jar

    If you want to use file.jar with Test then this will include it in the classpath: java -cp .;/jars/file.jar Test

    I advise experimenting from the command line.
    Also, provide us with error messages.
    Last edited by Turtle; 02-04-2010 at 10:01 PM. Reason: sp

  3. #3
    jojo is offline Member
    Join Date
    Dec 2009
    Posts
    36
    Rep Power
    0

    Default

    No, you don't understand:

    I run the jar file first, this is a application. (NO problems here)

    Then i have a Test.class outside the jar file, only in the same folder.
    The Test class contains Class.forName("class inside the jar file");
    So i can use reflection on this class.

    but i have to include the jar file in some way, else it keeps printing classnotfoundexception

    Thanks for the reply though

  4. #4
    Turtle is offline Member
    Join Date
    Nov 2007
    Location
    New Zealand
    Posts
    36
    Rep Power
    0

    Default

    Including the classpath as I suggested works.

    java -cp .;jars/file.jar Test

    Otherwise you have given the wrong class name.

  5. #5
    jojo is offline Member
    Join Date
    Dec 2009
    Posts
    36
    Rep Power
    0

    Default

    Ok, sorry, didn't try it yet. I'll try tomorrow and let you know.
    Thanks for the reply!

  6. #6
    jojo is offline Member
    Join Date
    Dec 2009
    Posts
    36
    Rep Power
    0

    Default

    Finnaly, somebody who helps me correctly.

    Thank you very much!

    SOLVED!
    Last edited by jojo; 02-04-2010 at 11:06 PM.

Similar Threads

  1. How to set ClassPath?
    By kishan in forum Advanced Java
    Replies: 5
    Last Post: 12-11-2009, 08:24 AM
  2. Classpath
    By JavaJunkie in forum New To Java
    Replies: 1
    Last Post: 04-07-2009, 08:17 AM
  3. help me to set classpath
    By srinivaspuvvala in forum Java Servlet
    Replies: 3
    Last Post: 01-18-2009, 08:13 PM
  4. Classpath
    By Preethi in forum New To Java
    Replies: 5
    Last Post: 06-20-2008, 10:00 AM
  5. Classpath on mac osx
    By jacobb in forum JDBC
    Replies: 0
    Last Post: 06-12-2008, 10:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •