| | |
Class.forName(String ClassName) throwing ClassNotFoundException
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
He says he is trying it from outside of the IDE.
@OP, you are obviously contradicting yourself when you say you know the basics of the classpath then talk about moving to the source directory. You also contradict yourself about those points when I ask you for the classpath, and you give me a package path style reference to a source file, then do the same thing when I ask after the full filepath of the actual class (not source file) to be loaded.
Now, provide me with the classpath you use to execute the command (if none, say none), and provide me with the full classname with package (class name not source file name), and provide me with the full filepath to the class to be loaded (full filepath). Also, provide me with the full filepath to the directory in which you find yourself when you execute the command, and provide the full and exact command you used to execute the command, and provide me with the full stacktrace, not your own generated error message.
@OP, you are obviously contradicting yourself when you say you know the basics of the classpath then talk about moving to the source directory. You also contradict yourself about those points when I ask you for the classpath, and you give me a package path style reference to a source file, then do the same thing when I ask after the full filepath of the actual class (not source file) to be loaded.
Now, provide me with the classpath you use to execute the command (if none, say none), and provide me with the full classname with package (class name not source file name), and provide me with the full filepath to the class to be loaded (full filepath). Also, provide me with the full filepath to the directory in which you find yourself when you execute the command, and provide the full and exact command you used to execute the command, and provide me with the full stacktrace, not your own generated error message.
Last edited by masijade; Jun 22nd, 2009 at 1:55 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jun 2009
Posts: 39
Reputation:
Solved Threads: 0
•
•
•
•
provide me with the classpath you use to execute the command (if none, say none),
•
•
•
•
provide me with the full classname with package (class name not source file name),
•
•
•
•
provide me with the full filepath to the class to be loaded (full filepath).
•
•
•
•
provide me with the full filepath to the directory in which you find yourself when you execute the command,
•
•
•
•
and provide the full and exact command you used to execute the command,
java -Xmx512m au.com.allhomes.listing.harvester.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/rsearch.html --listingType residentialSale --parserConfigImpl au.com.allhomes.listing.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/build/classes/sample/data/local_url_map.properties --outputXml results-realestate.xml --pageType listingPage And getting the anything from printStackTrace , tried below code -
Java Syntax (Toggle Plain Text)
StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); e.getStackTrace(); System.out.println("Error = " + sw.toString()); throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
•
•
•
•
I am not providing any classpath to the cmd.this is the command m hitting with cmd -
•
•
•
•
C:\Harvester\build\classes\au\com\allhomes\listing\harvester\harness\ListingTestHarnessConfiguration.class
•
•
•
•
C:\Documents and Settings\pritam\Desktop\au\com\allhomes\listing\harvester\parse\RealEstateCoParserConfiguration.java
•
•
•
•
Executing the (above) said command from 'C:\'
•
•
•
•
java -Xmx512m au.com.allhomes.listing.harvester.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/rsearch.html --listingType residentialSale --parserConfigImpl au.com.allhomes.listing.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/build/classes/sample/data/local_url_map.properties --outputXml results-realestate.xml --pageType listingPage
And getting the anything from printStackTrace , tried below code -
Java Syntax (Toggle Plain Text)
StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); e.getStackTrace(); System.out.println("Error = " + sw.toString()); throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Java Syntax (Toggle Plain Text)
e.printStackTrace(); throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Last edited by masijade; Jun 23rd, 2009 at 3:53 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jun 2009
Posts: 39
Reputation:
Solved Threads: 0
•
•
•
•
Okay, so what is the value of the System CLASSPATH environment variable?
this is System CLASSPATH environment variable
•
•
•
•
Here I wanted the class name (e.g. au.com.allhomes.listing.harvester.harness.ListingTestHarnessConfiguration)
•
•
•
•
Compiled class filepath not the source file path, I couldn't, to tell you the truth, care less about the source file at this point, but I assume the above (where I wanted the classname) is it, and I will assume the classname I provided is correct.
C:\Harvester\build\classes\au\com\allhomes\listing\harvester •
•
•
•
Well, if you are executing directly from C:\, and not from C:\Harvester\build\classes\ (assuming '.' is in the System CLASSPATH), then of course it is ClassNotFound (depending on what the system classpath is). You should actually be getting a ClassNotFound on the "main" class.
and how the user vairable 'classpath' and the 'CLASSPATH' (its in capital, which i get to see often) from System variables list below it...?Plz explain me this too,even if its the out of scope of the post.
•
•
•
•
why not simply
and let the stacktrace print to STDERR. It's only to get the complete stacktrace, and you can, if you want, remove it later.Java Syntax (Toggle Plain Text)
e.printStackTrace(); throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Error: Cannot read the urlConfigFile [/Harvester/build/classes/sample/data/local
_url_map.properties]
java ListingTestHarness <options>
Where options include:
--inputHtml <htmlFile> The HTML file to parse.
--listingType <residentialSale | commercialSale | businessSale | ruralSale |
residentialRental | commercialRental>
--parserConfigImpl <parserConfigImpl> The parser configuration to use.
--parserClassImpl <parserClassImpl> [Optional]: The parser class to use.
--urlConfigFile <urlConfigFile> A mapping of remote URLs to local te
st resources.
--pageType <listingPage | searchPage> The type of HTML page being harvested.•
•
Join Date: Jun 2009
Posts: 39
Reputation:
Solved Threads: 0
Also I noticed one thing with the netbeans behavour, which is very strange for me.
If I change the code, like the test/string inside
throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Like as u can see i put the ** in the string and compiled the project again.Now if i execute it from the cmd i cant see the change in the output exception i got.
what wrong with my concepts..??
If I change the code, like the test/string inside
throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Like as u can see i put the ** in the string and compiled the project again.Now if i execute it from the cmd i cant see the change in the output exception i got.
what wrong with my concepts..??
'.' is the "current" directory symbol.
How to get the value of an environment variable is an OS question, but for Windows type "set CLASSPATH" (and it should be uppercase not lowercase).
As far as the error posted above, that is not one that has to do with the problem you say you've been having, and to solve that one does C:\Harvester\build\classes\sample\data\local exist? Is it locked? Do you have permission to it?
How to get the value of an environment variable is an OS question, but for Windows type "set CLASSPATH" (and it should be uppercase not lowercase).
As far as the error posted above, that is not one that has to do with the problem you say you've been having, and to solve that one does C:\Harvester\build\classes\sample\data\local exist? Is it locked? Do you have permission to it?
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
•
•
Also I noticed one thing with the netbeans behavour, which is very strange for me.
If I change the code, like the test/string inside
throw new IllegalArgumentException("Failed to load** parserConfigImpl [" + parserConfigurationClassName + "]: Class not found");
Like as u can see i put the ** in the string and compiled the project again.Now if i execute it from the cmd i cant see the change in the output exception i got.
what wrong with my concepts..??
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jun 2009
Posts: 39
Reputation:
Solved Threads: 0
Thnx.Yes i had noticed this thing before.I used to get the exception cannot find the file local_url_propeties because i had moved the folder data for some experimenting purpose.
And when i realize this i kept it back.Now I had did it again and resolved with that prev error.
The error I am facing now is this exception I am talking about -
au.com.allhomes.listing.harvester.parse.
RealEstateCoParserConfiguration is my implementation of the
interface which I need to pass as a 'parserConfigImpl' parameter to the cmd.
But it throws the exception classNotFound..??
sorry if i confused u between these both errors.
And when i realize this i kept it back.Now I had did it again and resolved with that prev error.
The error I am facing now is this exception I am talking about -
•
•
•
•
Error: Failed to load parserConfigImpl [au.com.allhomes.listing.harvester.parse.
RealEstateCoParserConfiguration]: Class not found
java ListingTestHarness <options>
Where options include:
--inputHtml <htmlFile> The HTML file to parse.
--listingType <residentialSale | commercialSale | businessSale | ruralSale |
residentialRental | commercialRental>
--parserConfigImpl <parserConfigImpl> The parser configuration to use.
--parserClassImpl <parserClassImpl> [Optional]: The parser class to use.
--urlConfigFile <urlConfigFile> A mapping of remote URLs to local te
st resources.
--pageType <listingPage | searchPage> The type of HTML page being harvested.
RealEstateCoParserConfiguration is my implementation of the
interface which I need to pass as a 'parserConfigImpl' parameter to the cmd.
But it throws the exception classNotFound..??
sorry if i confused u between these both errors.
Lets try to cut this short. Execute the command as follows:
or
Java Syntax (Toggle Plain Text)
java -Xmx512m -cp C:\Harvester\build\classes au.com.allhomes.listing.harvester.harness.ListingTestHarness ...
Java Syntax (Toggle Plain Text)
cd C:\Harvester\build\classes java -Xmx512m -cp . au.com.allhomes.listing.harvester.harness.ListingTestHarness ...
Last edited by masijade; Jun 23rd, 2009 at 5:13 am. Reason: And please stop sending me PM's. Keep the conversation here and I'll get to it when I get to it.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Jun 2009
Posts: 39
Reputation:
Solved Threads: 0
•
•
•
•
Lets try to cut this short. Execute the command as follows:
orJava Syntax (Toggle Plain Text)
java -Xmx512m -cp C:\Harvester\build\classes au.com.allhomes.listing.harvester.harness.ListingTestHarness ...
Java Syntax (Toggle Plain Text)
cd C:\Harvester\build\classes java -Xmx512m -cp . au.com.allhomes.listing.harvester.harness.ListingTestHarness ...
C:\>java -Xmx512m -cp au.com.allhomes.listing.harvester.harness.ListingTestHarn ess --inputHtml /Harvester/build/classes/sample/data/rsearch.html --listingType residentialSale --parserConfigImpl au.com.allhomes.listing.harvester.parse.RealE stateCoParserConfiguration --urlConfigFile /Harvester/build/classes/sample/data/ local_url_map.properties --outputXml results-realestate.xml --pageType listingPa ge Unrecognized option: --inputHtml Could not create the Java virtual machine.
[QUOTE=masijade;897587]
Got this after above -
Java Syntax (Toggle Plain Text)
Exception in thread "main" java.lang.NoClassDefFoundError: au/com/allhomes/listi ng/harvester/harness/ListingTestHarness Caused by: java.lang.ClassNotFoundException: au.com.allhomes.listing.harvester.h arness.ListingTestHarness at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: au.com.allhomes.listing.harvester.harness.Listing TestHarness. Program will exit.
![]() |
Similar Threads
- java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver (Java)
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver (Java)
- error: The value for the useBean class attribute is invalid (JSP)
- JDBC Driver for SQL Server 2005, Class not found Exception (Java)
- org.apache.jasper.JasperException: Unable to load class for JSP (JSP)
- Help with displaying text through GUI interface (Java)
- resultset updatable (Oracle)
- MySQL drivers not loading? (Java)
- Trying to overload + for class to add to string 'is illegal' (C)
Other Threads in the Java Forum
- Previous Thread: null pointer exception problem
- Next Thread: How can login the remote system using java
| Thread Tools | Search this Thread |
android api applet application array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads time tree unlimited utility webservices windows






