• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't Make Class Path Work  RSS feed

 
Al Johnston
Ranch Hand
Posts: 99
Flex Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone.

We have a jar file that we need to instantiate. The jar file is provided by a vendor and resides in directory: C:\Program Files (x86)\Quova\GeoDirectory6.1\jar. I created code to test the application and then tried to define a classpath for the app. In windows, I did the following under the user's environmental variables:

CLASSPATH=c:\classes;C:\Program Files (x86)\Quova\GeoDirectory6.1\jar\geodirectoryapi.jar

c:\classes is where I have my test app running:

c:\classes\com\...\IPValidationTest.java

I find that that only way to make the IPValidationTest run is to do so as follows:

c:\classes>java -cp . com...IPValidationTest

(I thought that setting the environmental variable would mean that I would not have to use -cp...)

In any event, when I do that, it at least loads my IPValidationTest object. But, once it hits main I get the message:

No Class Def Found com...geodirectoryapi.QuovaIPFieldMap

The QuovaIPFieldMap is part of the geodirectoryapi.jar file and is the first object from the vendor that my test code instantiates. I think I've set my environmental variables up correctly but this is not working. Can someone please help me?

 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you just set up a system classpath? If there was nothing in the system classpath before, delete it and use the -cp tag.
If there was anything in the classpath before, add .; to its beginning.

That might help.

If there is no system/user classpath, the java tool looks for classes starting in the current directory. If there is a system classpath, it looks in the classpath. If there is no . and the classes you want are in the current directory, it might never find the classes.

And welcome to JavaRanch
 
Al Johnston
Ranch Hand
Posts: 99
Flex Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Campbell for the welcome and for the help.

I tried setting up a system classpath as you suggested (along with my user classpath that I already have defined). I did so as follows:

Variable Name:CLASSPATH

Variable Value:C:\Program Files (x86)\Quova\GeoDirectory6.1\jar\geodirectoryapi.jar

I still got the message that the compiler can't find the class...



 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried deleting that system classpath and using the -cp option? Or add a . to your classpaths?

Can't think if anything else to suggest just at the present (sorry), but have a look in the Java™ Tutorials. Also the javac tool page and java tool page and read the little it tells you about class paths.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any luck yet? If all else fails, try unzipping the .jar into the folder containing all your other Java code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!