I got an email as such:

I think your problem it's about class loading. When calling something
like Class.forName("MyClassHere") (ex: when loading jdbc driver) you
should have your class.jar in your class path. Either compile your
program with -cp option, specifying your path to your compiled
class.jar or just put in your CLASSPATH enviorment variable the path
to those classes/jar.


Dumitru Malaescu

I thank you for showing how to use Class.forName for ones own class.
The point was that I just found it easier to change the code thus.
Nothing wrong with that is there?

On Sep 18, 11:33 am, Douglas <[email protected]> wrote:
> Hey All;
>
> Here is a little information about using reflection in case anyone is
> interested.
>
> http://java.sun.com/developer/technicalArticles/ALT/Reflection/index....
>
> http://java.sun.com/developer/technicalArticles/JavaLP/Interposing/#c...
>
> I was working through some apps from Herb Schildt's Java Programming
> Cookbook
>
> and could not get Class.forName("MyClassHere") to find my class.
>
> This works for the fully qualified java classes such as
> "java.lang.String".....
>
> My solution was to create new instances of MyClassHere like this:
>
> try {
>             MyClassHere mch = new MyClassHere();
>             Class c = mch.getClass();
> ...........
>     } catch.................
>
> This is also the case for many of the examples on the two sites that I
> provided.
>
> What's my point? Reflection can be a powerful tool if you are careful
> with it and don't over use it.

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to