Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Class not found exception for JUnit
Class not found exception for JUnit [message #668531] Fri, 06 May 2011 06:33 Go to next message
Vishal  is currently offline Vishal Friend
Messages: 3
Registered: May 2011
Junior Member
Hi,
I have been trying to execute for Junit s in eclipse environment.

I have been running the Junit as follows :
Right Click on Junit Test file -> Run As -> Junit Test

On the console I get the error

Class not found packagename.MyJunitTest
java.lang.ClassNotFoundException: packagename.MyJUnitTest
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)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC lasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)

Basically it is complaining that it is not able to find the JUnit class file which I am trying to execute.


Java Build path is also set as follows :
Build Path -> Configure Build Path -> Java Build Path -> Source tab

Default Output Folder :
FullPathOfTheProject/target/classes

Any Help here would be appreciated.

Thanks and Regards,
Vishal
Re: Class not found exception for JUnit [message #668610 is a reply to message #668531] Fri, 06 May 2011 12:21 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

Is MyJUnitTest.java in the same folder as the source code you're trying
to test? If not, is it nevertheless in a folder that is or whose parent
is a Source Folder?

On 2011.05.06 0:33, Vishal wrote:
> Hi, I have been trying to execute for Junit s in eclipse environment.
> I have been running the Junit as follows : Right Click on Junit Test
> file -> Run As -> Junit Test
> On the console I get the error
> Class not found packagename.MyJunitTest
> java.lang.ClassNotFoundException: packagename.MyJUnitTest
> 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)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC
> lass(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadC
> lasses(RemoteTestRunner.java:425)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:445)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R
> emoteTestRunner.java:386)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
>
> Basically it is complaining that it is not able to find the JUnit class
> file which I am trying to execute.
>
> Java Build path is also set as follows :
> Build Path -> Configure Build Path -> Java Build Path -> Source tab
> Default Output Folder :
> FullPathOfTheProject/target/classes
>
> Any Help here would be appreciated.
> Thanks and Regards, Vishal
Re: Class not found exception for JUnit [message #668620 is a reply to message #668610] Fri, 06 May 2011 12:53 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

(Sorry got distracted...)

Did you also ensure that you have the JUnit JARs in your project (via
Build Path)? I can't see your project, obviously, so I can only ask dumb
questions in an effort to help. Sorry if I'm not being much help.

On 2011.05.06 6:21, Russell Bateman wrote:
> Is MyJUnitTest.java in the same folder as the source code you're trying
> to test? If not, is it nevertheless in a folder that is or whose parent
> is a Source Folder?
>
> On 2011.05.06 0:33, Vishal wrote:
>> Hi, I have been trying to execute for Junit s in eclipse environment.
>> I have been running the Junit as follows : Right Click on Junit Test
>> file -> Run As -> Junit Test
>> On the console I get the error
>> [snip]
>
Previous Topic:delete me
Next Topic:Error adding a CVS repository
Goto Forum:
  


Current Time: Fri Apr 19 07:06:34 GMT 2024

Powered by FUDForum. Page generated in 0.03102 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top