3

I am trying to run an HelloWorld kind of program for Scala , in Intellij.

My code is:

package helloscala

object HelloScala { def main(args: Array[String]) { Console.println("Hello, world!"); } }

I am clueless about the error , that is prompted by the INtellij IDE.

 JDK is JDK5

Error is:

java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Exception in thread "main"

Any input would be great.

4
  • 2
    Is there any particular reason that you are using Java 5? If not then just install a newer JDK.
    – maba
    Commented Apr 22, 2013 at 5:54
  • Well my current code base is Java 5. I don't want to risk that Commented Apr 22, 2013 at 5:55
  • @user1993412 what scala version are you using?
    – om-nom-nom
    Commented Apr 22, 2013 at 5:58
  • version is scala 2.9.2 Commented Apr 22, 2013 at 6:00

2 Answers 2

5

Scala 2.10 doesn't support Java 5.

Software Requirements: The Scala software distribution can be installed on any Unix-like or Windows system. It requires the Java runtime version 1.6 or later.

4
  • He says he is using scala 2.9.2. I think you can remove the 2.10 version from the answer. I think the Software Requirements are valid across all Scala versions.
    – maba
    Commented Apr 22, 2013 at 6:03
  • @Kaz Sera , I m using Scala 2.9.2 Commented Apr 22, 2013 at 6:05
  • Yes , it works with JDK 6 only , I think so , if it is feasible to update my code base easily , I would do it. Thanks Guys for the inputs !!! Commented Apr 22, 2013 at 6:16
  • I would recommend going all the way to JDK7. Commented Apr 22, 2013 at 16:59
0

Use JDK 7 + sbt-idea plugin.

SBT is the preferred build tool

I recommend my project skeleton for setting it all up. Intllij + SBT (+eclipse if you so want to)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.