Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsClass.forName = ClassNotFound (3.5 & 3.6)
https://www.eclipse.org/forums/index.php/mv/msg/172132/547576/#msg_547576
Originally posted by: natgross.ATgmail.com
My system is Suse Linux 11.2, Gnome, 32 bit.
Sun jvm jdk1.6.0_16.
Eclipse 3.5 or 3.6.
Class.forName ALWAYS fails. Even the following simple program.
public class TestForName {
public TestForName(String name) {
Class<?> c = test(name);
System.out.println("TestForName() Class=" + c );
}
public static void main(String[] args) {
//*any* class, even from same directory, even this class(!), even those from java.lang, FAIL!
new TestForName("Thread");
}
}
Please advise,
nat.
Thanks]]>2010-07-18T23:01:56-00:00Re: Class.forName = ClassNotFound (3.5 & 3.6)
https://www.eclipse.org/forums/index.php/mv/msg/172132/547619/#msg_547619
> My system is Suse Linux 11.2, Gnome, 32 bit.
> Sun jvm jdk1.6.0_16.
> Eclipse 3.5 or 3.6.
>
> Class.forName ALWAYS fails. Even the following simple program.
>
>
> public class TestForName {
>
> public TestForName(String name) {
> Class<?> c = test(name);
> System.out.println("TestForName() Class=" + c );
> }
>
> private Class<?> test(String name) {
> Class<?> c=null;
> try {
> c = Class.forName(name);
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> }
> return c;
> }
>
> public static void main(String[] args) {
> //*any* class, even from same directory, even this class(!), even those from java.lang, FAIL!
> new TestForName("Thread");
> }
> }
>
> Please advise,
> nat.
Please read the spec of Class#forName before attempting to
use it. The spec says:
Parameters:
className the fully qualified name of the desired class.
Returns:
the Class object for the class with the specified name.
There is no type "Thread" in the Java runtime, there exists
a type "java.lang.Thread" though.
HTH & Greetings from Bremen,
Daniel Krügler]]>Daniel Krügler2010-07-19T07:36:57-00:00Re: Class.forName = ClassNotFound (3.5 & 3.6)
https://www.eclipse.org/forums/index.php/mv/msg/172132/547618/#msg_547618
are showing has nothing to do with OSGi and or an Eclipse plugin (you
have a main-method) so I'd suggest if you still have troubles getting
this to work to post on some Java-Beginners forum.
Tom
Am 19.07.10 01:01, schrieb nat G:
> My system is Suse Linux 11.2, Gnome, 32 bit.
> Sun jvm jdk1.6.0_16.
> Eclipse 3.5 or 3.6.
>
> Class.forName ALWAYS fails. Even the following simple program.
>
>
> public class TestForName {
>
> public TestForName(String name) {
> Class<?> c = test(name);
> System.out.println("TestForName() Class=" + c );
> }
>
> private Class<?> test(String name) {
> Class<?> c=null;
> try {
> c = Class.forName(name);
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> }
> return c;
> }
>
> public static void main(String[] args) {
> //*any* class, even from same directory, even this class(!), even those from java.lang, FAIL!
> new TestForName("Thread");
> }
> }
>
> Please advise,
> nat.
> Thanks]]>Thomas Schindl2010-07-19T07:37:34-00:00Re: Class.forName = ClassNotFound (3.5 & 3.6)
https://www.eclipse.org/forums/index.php/mv/msg/172132/547801/#msg_547801
Originally posted by: natgross.ATgmail.com
On Sun, 18 Jul 2010 19:01:56 -0400, nat G wrote:
> My system is Suse Linux 11.2, Gnome, 32 bit. Sun jvm jdk1.6.0_16.
> Eclipse 3.5 or 3.6.
>
> Class.forName ALWAYS fails. Even the following simple program.
>
>
> public class TestForName {
>
> public TestForName(String name) {
> Class<?> c = test(name);
> System.out.println("TestForName() Class=" + c );
> }
>
> private Class<?> test(String name) {
> Class<?> c=null;
> try {
> c = Class.forName(name);
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> }
> return c;
> }
>
> public static void main(String[] args) {
> //*any* class, even from same directory, even this class(!), even
> those from java.lang, FAIL! new TestForName("Thread");
> }
> }
Thanks, Daniel & Tom. It was my obvious error.
In the past, I have had true Class.forName problems with Eclipse with jdbc,
so now, I quickly jumped the gun, blaming Eclipse. How dare I! :)]]>2010-07-19T15:20:47-00:00