Force IntelliJ project to use Scala compatible with Java 6 - java

I have this project in IntelliJ IDEA which uses Scala. I need it to be compatible to run on Java v1.6. I configured the project as such, and I even only have Java 6 in my development environment. However, when I build the project and run it I get the following:
Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/Function1 : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at myproject.Main.main(Main.scala)
It appears as so there's still some class in my project compiled for Java 8. Could it be that the Scala libraries I have are compiled for Java 8? These are the libraries downloaded by IntelliJ IDEA. How can I solve this?

Related

exceptions on executing hdfs namenode -format

I get following exception, when I execute hdfs namenode -format command:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/util/PlatformName : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.hadoop.util.PlatformName. Program will exit.
This issue is related to java version mismatch i.e the version with which hadoop is compiled is higher than the jdk version installed on your machine.Install proper jdk version and set JAVA_HOME properly

connect to server socket running in eclipse

I want to connect a Client written in Perl and running via command line to a server written in java and running in Eclipse. It don't work, it's because the server is running in Eclipse ? when I try to run the server via command line I got an error, but in eclipse it work fine
java MultiThreadServer
Exception in thread "main" java.lang.NoClassDefFoundError: MultiThreadServer (wrong name: inet/MultiThreadServer)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I think that is a classpath issue.
The NoClassDefFoundError indicates that the classloader can't find the .class file that you're trying to use. You should set the classpath when executing your code.
See
Classpath in Java

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing in Intellij

I used Intellij Idea 12 Community edition. I am trying to create test case for my class by creating test case. When i run my test case it says
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:44)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
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)
... 25 more
How would i run test case in Intellij. I included the junit4.11 jar file to my module
Did you include the hamcrest-core-1.3.jar file in your classpath? If not included means include that jar and try once again.
add junit.jar to your project dependence.
you may also need to add hamcrest.jar in addition.
Open File->Project Structure,Click Modules->Dependences,add junit.jar.
Latest version of hamcrest-all is available at:
https://search.maven.org/search?q=a:hamcrest-all
Download this version (as opposed to the hamcrest-core) and that should do it.
If you come across this (and a few other threads) on this error and adding the jar to dependencies doesn't work, you will need to add to the general java classpath.
I encountered this error in OSX where maven would download the dependency, but not find it when in fork mode.
Adding all the hamcrest jars to Library/Java/Extensions finally fixed the problem when nothing else would.

hadoop wordcount Unsuppored Major.Minor version 51.0 ERROR

I created a jar file for wordcount in Hadoop 1.1.1 while running world count its giving me following error:
hduseros#MT2012018:/usr/local/hadoop$ bin/hadoop jar playground/wordcount.jar org.apache.hadoop.examples.WordCount /user/input/playground /user/output1
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/examples/WordCount : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
This error comes when your hadoop system is running lower Java version than the one used to compile your MapReduce code.
Check java versions of your hadoop system and system you used to compile your code with "java -version".
The error is because of jdk mismatch on the machine which you are compiling and the machine on which you are running the jar. Match both the versions of jdk.

How to run a project that written in NetBeans on another computer?

I wrote a project in NetBeans IDE in my computer, and I ran it. That was OK. I transferred it into my Friend's computer. I ran it with NetBeans, but I got these errors:
java.lang.UnsupportedClassVersionError: friendspro/Server/RunServer : Unsupported major.minor version 51.0
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$000(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:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: friendspro.Server.RunServer. Program will exit.
Exception in thread "main" Java Result: 1
///
When I ran my project in my computer in CMD, I got the same error:
C:\Users\Blue\Desktop\FriendsPro\src\friendspro\Server>java RunServer -ORBIniti
alRef NamingServic=corbaloc::localhost:1049/NameService
Exception in thread "main" java.lang.NoClassDefFoundError: RunServer (wrong name
: friendspro/Server/RunServer)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)
It's not the same error. Your friend has an older Java version. Here's how to target older Java versions in NetBeans: Target JDK for Java Applications.
You are running your program incorrectly. You need to do
java friendspro.Server.RunServer -ORBIniti ...
in your main directory (probably bin or src).
On your computer, open CMD, cd to your source directory and then, as Banthar specified,
java friendpro.Server.RunServer ...

Categories

Resources