NoClassDefFoundError with RC

13 views
Skip to first unread message

keffe

unread,
Dec 28, 2010, 5:10:45 AM12/28/10
to Selenium Users
Hello!

I have installed Selenium RC and now tryning to use through CMD. I can
compile my file with javac but when I try to run my java file I always
get the this:

C:\>cd tests

C:\tests>javac Wiki.java

C:\tests>java Wiki
Exception in thread "main" java.lang.NoClassDefFoundError: Wiki
Caused by: java.lang.ClassNotFoundException: Wiki
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Wiki. Program will exit.

What is wrong? I have googled som and I think it is something wrong
with my classpath, but I can´t understand what. I have tried to change
it according to some tutorials but nothing works. Is there any one who
can give me some suggestion of how I can fix this.

//Jens

Smruti Ranjan Sahoo

unread,
Dec 28, 2010, 12:00:55 PM12/28/10
to seleniu...@googlegroups.com
Well, this is a pure java class path issue and nothing to do with selenium.
I would suggest use an IDE like Eclipse to write any java code.
If you still want to run it from command line, then take care of few things.

First of all make sure the Wiki  class has a main method(public static void main(String args[]))

1. put the .class file to the proper package.
2. set the class path to the directory which contians the class files. and the
    dpendent jar files.
3. while running the main class use the fully qualified class name.
   like java com.selenium.Wiki


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


keffe

unread,
Dec 29, 2010, 5:33:27 AM12/29/10
to Selenium Users
Ok. Thanks for your answer.

I have tried everything now but it won´t work. I have the correct
packages and my Path contains the directory to the class files. I give
up. Can you give me any links to some good tutorials how to work with
Selenium and Eclipse.

//Jens

On 28 Dec, 18:00, Smruti Ranjan Sahoo <smrutil...@gmail.com> wrote:
> Well, this is a pure java class path issue and nothing to do with selenium.
> I would suggest use an IDE like Eclipse to write any java code.
> If you still want to run it from command line, then take care of few things.
>
> *First of all make sure the Wiki  class has a **main method(public static
> void main(String args[]))*
>
> 1. put the .class file to the proper package.
> 2. set the class path to the directory which contians the class files. and
> the
>     dpendent jar files.
> 3. while running the main class use the fully qualified class name.
>    like java com.selenium.Wiki
>
> > "Selenium Users" group.> To post to this group, send email toseleni...@googlegroups.com.
> > To unsubscribe from this group, send email to>selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>
> > .

BillR

unread,
Dec 29, 2010, 1:35:02 PM12/29/10
to Selenium Users
You don't mention exactly what you tried and whether the error was
always the same. It is odd that the missing class is the one you have
just compiled. Does this work for you? x.java:

---
public class x {
public static void main(String[] args) {
System.out.println("Hi world");
}
}
---
$ javac x.java
$ java x
Hi world
> > > To unsubscribe from this group, send email to>selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe­@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/selenium-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

keffe

unread,
Dec 30, 2010, 3:29:14 AM12/30/10
to Selenium Users
Hi

No, it dosen´t work either. I get this:

C:\>cd tests

C:\tests>javac x.java

C:\tests>java x
Exception in thread "main" java.lang.NoClassDefFoundError: x (wrong
name: tests/
x)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:
283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: x. Program will exit.

I really don´t know whats wrong. Do you have any suggestions?

//Jens
> > > > You received this message because you are subscribed to the Google Groups> > > "Selenium Users" group.> To post to this group, send emailtosel...@googlegroups.com.> > > To unsubscribe from this group, send email to>selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe­@googlegroups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/selenium-users?hl=en.-Hide quoted text -

BillR

unread,
Dec 30, 2010, 1:56:30 PM12/30/10
to Selenium Users
Is this the very first time you have tried to use java on this
machine? This is the most basic sort of test. It just works for me,
and it's my first java-on-windows install (XP). I would go to a java
group for further help. Maybe there's something wrong about your java
installation, which somehow allows javac to work but not java.
> > > > >http://groups.google.com/group/selenium-users?hl=en.-Hidequoted text -
>
> > > - Show quoted text -- Hide quoted text -

Krishna chaitanya

unread,
Jan 10, 2011, 8:35:03 AM1/10/11
to selenium-users
where is the class file located after compiling ..

Just google NoClassDefFoundError + wrong name .. There are lot of
results matching this ..

> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Krishna chaitanya

unread,
Jan 10, 2011, 8:39:52 AM1/10/11
to selenium-users
Open this url and search for NoClassDefFoundError ..

http://www.jarticles.com/package/package_eng.html
Reply all
Reply to author
Forward
0 new messages