This is just too wierd! My classes are in c:\javaclasses My java source files are in c:\java\FoodCoster I'm not using packages. From the command prompt, if I navigate to c:\java\FoodCoster and execute java -classpath c:\javaclasses Driver2 I get 3 class not found exceptions. Within my IDE ( JCreator ), the program runs with no problems. Settings in the IDE indicate c\javaclasses as being prepended to the CLASSPATH at run-time. What is up with this? I even downloaded JPadPro and the same scenario: fine in the IDE, class not found exceptions from the command line. [ October 08, 2002: Message edited by: Peter Simard ]
OK...latest configuration. Made all files members of package com.pasimard New directory: c:\com\pasimard // .class files live here
after compiling directory structure looks like: c:\com\pasimard\com\pasimard invoking from .bat file javaw -classpath c:\com\pasimard com.pasimard.Driver2 results = 3 JOptionPane popups telling me class not found exception. once again, the program runs fine in IDE [ October 08, 2002: Message edited by: Peter Simard ]
In response to your first post... Are you certain that all of the necessary class files are in c:\javaclasses ? Otherwise, it looks like you're doing it right. [ October 08, 2002: Message edited by: Dirk Schreckmann ]
General response... I don't think that there is enough information for someone else to pinpoint your mistake. Basically, the location of the classes necessary to run your application must be specified in the classpath setting.
Hi Dirk; First, thanks for your answer. In order to ensure I've got ALL the classes in the proper place I set up a test directory structure, and made all the files members of a package. I get the same response, 3 class not found exceptions, though from within the IDE it runs fine.
package name is: com.panvox Directory structure is: C:\FCPro\source C:\FCPro\com\panvox from the command prompt I enter: java -classpath C:\FCPro com.panvox.Driver2 This should work, correct? Considering that it throws the exceptions, could there be something going on, when i lauch the application outside the confines of the IDE, that might have something to do with inner classes i have defined? Also my CLASSPATH environment variable is: .;C:\;C:\j2sdk1.4.1\jre\lib\rt.jar;C:\j2sdk1.4.1\lib\tools.jar;C:\j2sdk1.4.1\jre\lib\ext\mysql-connector-j-2.0.14-bin.jar
HOOORAYYY!!! Finally got it running!!....and learned a lot about class paths in the process... OK...When I was getting the 3 "class not found exception" popups, those were notices/JOptionPanes I had defined in the catch block for the SQL exception. I got 3 because there are 3 SQL queries that are executed when the program loads. But I had worded them in such a way that they "sounded" like they were system generated! Once I had determined that it was these "generic" error notices/popups I had coded, what were confusing me I modified each notice to tell me exactly where it was being generated, and in that way i was able to determine that the JVM was not finding the mysql jdbc driver, when launching from the command line. (Why it worked within the IDE I'd love to know ). So going back to the driver instructions I unpacked the files placed them in my application directories where specified and removed the classpath entry in the environment variables which pointed to the driver binary .jar file. ( This also makes it easier to transport the application as I won't need to mess with the users classpath ) I can't thank all of you enough, for your time, ideas, and patience.
Your classpath-learning experience appears to have been very similar to my own. I was strictly a JCreator user and was pleased that it took care of all that ugly stuff for me and just let me learn how to program. Then one day I decided it was time to take the plunge and learn the nitty-gritty details. After posting a few questions very similar to your postings, it finally became clear to me how it all worked. Welcome to the world of those who understand the classpath. There are likely a few details that'll trip you up (like trying to access a class in some default package from a class in a declared package), but you'll figure it out. Good Luck.