Class.forName(String ClassName) throwing ClassNotFoundException

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2006
Posts: 2,431
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #21
Jun 23rd, 2009
By the first one, you did not enter the classpath.

By the second one, you seem to have a line break in the classname (cut-n-paste error).

Don't just print the error, print the command you used as well, and make sure you get the command right.
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 39
Reputation: multicoder is an unknown quantity at this point 
Solved Threads: 0
multicoder multicoder is offline Offline
Light Poster

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #22
Jun 23rd, 2009
I mean to say, I tried -
Case I)
C:\>java -Xmx512m -cp C:\Harvester\build\classes\au.com.allhomes.listing.harvest
er.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/r
search.html --listingType residentialSale --parserConfigImpl au.com.allhomes.lis
ting.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/
build/classes/sample/data/local_url_map.properties --outputXml results-realestat
e.xml --pageType listingPage
Unrecognized option: --inputHtml
Could not create the Java virtual machine.

Case II)
C:\>cd C:\Harvester\build\classes

C:\Harvester\build\classes>java -Xmx512m -cp . au.com.allhomes.listing.harvester
.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/rse
arch.html --listingType residentialSale --parserConfigImpl au.com.allhomes.listi
ng.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/bu
ild/classes/sample/data/local_url_map.properties --outputXml results-realestate.
xml --pageType listingPage
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find sy
mbol
symbol : class HarvesterConfigurationStub
location: package au.com.allhomes.listing.harvester
at au.com.allhomes.listing.harvester.harness.ListingTestHarness.<clinit>
(ListingTestHarness.java:11)
Could not find the main class: au.com.allhomes.listing.harvester.harness.Listing
TestHarness. Program will exit.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 39
Reputation: multicoder is an unknown quantity at this point 
Solved Threads: 0
multicoder multicoder is offline Offline
Light Poster

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #23
Jun 23rd, 2009
I think u mean -
java -XmX512m -cp C:\Harvester\build\classes au.com....

That is, space after C:\Harvester\build\classes to provide the classpath.
So for this i got below thing -
C:\>java -Xmx512m -cp C:\Harvester\build\classes au.com.allhomes.listing.harvest
er.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/r
search.html --listingType residentialSale --parserConfigImpl au.com.allhomes.lis
ting.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/
build/classes/sample/data/local_url_map.properties --outputXml results-realestat
e.xml --pageType listingPage
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find sy
mbol
symbol : class HarvesterConfigurationStub
location: package au.com.allhomes.listing.harvester
at au.com.allhomes.listing.harvester.harness.ListingTestHarness.<clinit>
(ListingTestHarness.java:11)
Could not find the main class: au.com.allhomes.listing.harvester.harness.Listing
TestHarness. Program will exit.
Also for 2nd one, i put -
C:\>cd C:\Harvester\build\classes

C:\Harvester\build\classes>java -Xmx512m -cp . au.com.allhomes.listing.harvester
.harness.ListingTestHarness --inputHtml /Harvester/build/classes/sample/data/rse
arch.html --listingType residentialSale --parserConfigImpl au.com.allhomes.listi
ng.harvester.parse.RealEstateCoParserConfiguration --urlConfigFile /Harvester/bu
ild/classes/sample/data/local_url_map.properties --outputXml results-realestate.
xml --pageType listingPage
I suppose there is a '.' to signify the current working directory as a classpath and I am getting this -
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find sy
mbol
symbol : class HarvesterConfigurationStub
location: package au.com.allhomes.listing.harvester
at au.com.allhomes.listing.harvester.harness.ListingTestHarness.<clinit>
(ListingTestHarness.java:11)
Could not find the main class: au.com.allhomes.listing.harvester.harness.Listing
TestHarness. Program will exit.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,431
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #24
Jun 23rd, 2009
Originally Posted by multicoder View Post
I think u mean -
java -XmX512m -cp C:\Harvester\build\classes au.com....

That is, space after C:\Harvester\build\classes to provide the classpath.
So for this i got below thing -
Of course I did, seeing as how I entered it that way. You copied it wrong.

I suppose there is a '.' to signify the current working directory as a classpath and I am getting this -
Of course, as mentioned earlier.

You are now getting a different error. This problem is solved.

Start a new thread with this new problem.
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 39
Reputation: multicoder is an unknown quantity at this point 
Solved Threads: 0
multicoder multicoder is offline Offline
Light Poster

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #25
Jun 23rd, 2009
Its just that we got rid of that exception, but in efforts to that we created a different problem.now we are playing to change the classpath in the command itself and the classloader can now create the object of 'RealEstateCoParserConfiguration' i.e. my implementation for the interface.
But in the process alters the classpath and cannot find the succeeding classes.
Is this right?or else i should post the new question for these classes can not find error...?Since now m getting cannot find symbol HarvesterConfigurationStub and getting exception at main
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,431
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
1
  #26
Jun 23rd, 2009
No we did not create a problem, simply got the code to run far enough for that already existing problem to be noticed. This thread is already too long IMHO, and this current error has nothing to do with the original error, so it is time for a new thread.

You are not "creating" any classpaths in your code, you are simply executing the program with a classpath so that it can find anything at all. It now looks as though you are attempting to compile some code within your code, which, as already said, is a new problem.

You are, however, in really very far over your head attemtping this SOS with the level of knowledge you've shown here for the basic tenants of the language that every programmer should learn as one of their first lessons.
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 39
Reputation: multicoder is an unknown quantity at this point 
Solved Threads: 0
multicoder multicoder is offline Offline
Light Poster

Re: Class.forName(String ClassName) throwing ClassNotFoundException

 
0
  #27
Jun 23rd, 2009
thnx masijade!
I taking this thing here -
http://www.daniweb.com/forums/post89...tml#post897723

And i know where i stand today and I have a dream about tomorow too!!zSo thnx a lot for helping around me and inspiring me.
And if somebody wont work just by the fear of people laughing at them then how he or she will learn.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC