-1

I'm new at Java programming language, so I need a short introduction for my mentioned environment. By compiling my code I'm getting some some errors like these:

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/JUnitCore Caused by: java.lang.ClassNotFoundException: org.junit.runner.JUnitCore 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:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

I'm very sorry if anyone felt annoyed of my question but my professor as well as students and tutors can't help me... all Windows/Ubuntu users argh. Google wasn't very informative.

Regards, Markus

Markus
  • 11
  • 1
  • 3
    Looks like junit is not on your classpath. – Uku Loskit Nov 25 '11 at 19:10
  • You might consider using a simple [Ant](http://ant.apache.org/) build file to handle classpath setup. – Barend Nov 25 '11 at 19:12
  • How are you trying to compile? From the command line or directly from Textmate? And what tools are the Windows/Ubuntu users using? I would expect Eclipse or NetBeans to normally be used for Java development, and both of those are available for Mac as well. – avh4 Nov 25 '11 at 19:14
  • @avh: It's not a compiletime error, it's a runtime error. – BalusC Nov 25 '11 at 19:17
  • I'm compiling with Textmate. There I get an error for Ant builds as well: "Searching for build.xml ...Could not locate a build file!" – Markus Nov 25 '11 at 19:19
  • >and if I compile on the default way, I get this: Exception in thread >"main" java.lang.ArrayIndexOutOfBoundsException: 0 > at Hello.main(Hello.java:16) > >Program exited with status 1. – Markus Nov 25 '11 at 19:21

2 Answers2

1

This is simply telling you JUnit is not in your classpath, you can edit your class path through an environment variable or use the -cp argument in the command line to specify a path (I think it can be either absolute or relative).

Hope that helps

jt78
  • 906
  • 2
  • 10
  • 22
1

To help yourself, you can use an IDE in Mac OS X (Eclipse, Intelij,
SpringSource Tool Suite. etc.)

TextMate is great... e.g : for ruby on rails... but for Java, i would use a more elaborate IDE. (Especially if you are new to it ;-) )

You will visually see right at the start when you try to import a class that you miss a jar in your build path for example ;-)

My 2 cents

Cygnusx1
  • 5,329
  • 2
  • 27
  • 39
  • Netbeans is a good option too. Decent editor that gets out of your way. JUnit especially nice. Keyboard shortcuts to create shell test class, and the shortcut keys to toggle between test class and real class. Very handy. – BillRobertson42 Nov 25 '11 at 19:27
  • I really like Textmate for nearly every language but for Java it seems a bit tricky to configure it correctly. But I'll do so, if I can get some help from you guys. Eclipse and Netbeans are a monster IDEs. For my cases of use, I'd like to prefer textmate at all. =) – Markus Nov 25 '11 at 19:35
  • Textmate is no more difficult to configure than other editors but you need to understand Unix paths and environments - java IDES like eclipse and netbeans take over the whole environment and do all the connections to java you need. – mmmmmm Nov 25 '11 at 20:13
  • Is somewhere a tutorial/post about the configuration? regards – Markus Nov 25 '11 at 21:52