Results 1 to 6 of 6
Thread: Classpath
- 02-04-2010, 05:03 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 36
- Rep Power
- 0
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:
but doesn't work. ANy idfeas???Java Code:@echo off C:> java "-classpath C:\Documents and Settings\xxx\Bureaublad\xxx\jars\file.jar" java Test echo Shutdown...DONE pauze
Thanks in advance!
- 02-04-2010, 09:00 PM #2
Member
- Join Date
- Nov 2007
- Location
- New Zealand
- Posts
- 36
- Rep Power
- 0
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 09:01 PM. Reason: sp
- 02-04-2010, 09:15 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 36
- Rep Power
- 0
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
- 02-04-2010, 09:31 PM #4
Member
- Join Date
- Nov 2007
- Location
- New Zealand
- Posts
- 36
- Rep Power
- 0
Including the classpath as I suggested works.
java -cp .;jars/file.jar Test
Otherwise you have given the wrong class name.
- 02-04-2010, 09:52 PM #5
Member
- Join Date
- Dec 2009
- Posts
- 36
- Rep Power
- 0
Ok, sorry, didn't try it yet. I'll try tomorrow and let you know.
Thanks for the reply!
- 02-04-2010, 10:04 PM #6
Member
- Join Date
- Dec 2009
- Posts
- 36
- Rep Power
- 0
Similar Threads
-
How to set ClassPath?
By kishan in forum Advanced JavaReplies: 5Last Post: 12-11-2009, 07:24 AM -
Classpath
By JavaJunkie in forum New To JavaReplies: 1Last Post: 04-07-2009, 07:17 AM -
help me to set classpath
By srinivaspuvvala in forum Java ServletReplies: 3Last Post: 01-18-2009, 07:13 PM -
Classpath
By Preethi in forum New To JavaReplies: 5Last Post: 06-20-2008, 09:00 AM -
Classpath on mac osx
By jacobb in forum JDBCReplies: 0Last Post: 06-12-2008, 09:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks