running job in hadoop - ERROR - java

I'm trying to run a program in hadoop ~ $ Desktop/HadoopProject2016.jar input output and i keep getting this error :
Exception in thread "main" java.lang.UnsupportedClassVersionError:
hadoop_project_16/AggregateJob : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(ClassLoader.java:803) at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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:425) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at
java.lang.ClassLoader.loadClass(ClassLoader.java:358) at
sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Also i dont know how to check the output... Is the error normal?

1) Check if your JRE (java version) of your project in your workspace(eg: eclipse properties window) is same as your java version in your machine from which you are running the hadoop jar command.
2) I am assuming that you are submitting the jar as
hadoop jar

Hadoop jars, you need to check them. Make sure all jars are updated (better bring in the latest version for every jar) and compatible with each other. You can find the version dependencies at http://www.mvnrepository.com/

Related

spark-shell command gives java error [duplicate]

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 4 years ago.
I am new to spark. Trying to do setup in my local machine (mac), which has java version 1.7.0_80.
Followed these steps :
Downloaded apache spark, version spark-2.3.1-bin-hadoop2.6.tgz, from
https://spark.apache.org/downloads.html.
Untared the file, renamed the folder to spak and moved it to
/usr/local/spark
in /usr/local/spark, ran this command :bin/spark-shell
Got this java error :
Rajeev: spark rajeevnair$ bin/spark-shell
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/spark/launcher/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
You need Java 8 to run Spark with a version greater than 2.2.0.
See the Spark documentatin for details:
Building Spark using Maven requires Maven 3.3.9 or newer and Java 8+. Note that support for Java 7 was removed as of Spark 2.2.0.
So your options are upgrading Java or using an older version of Spark.

Raspberry pi - java - Serial Com

I've got a serious problem with my Raspberry Pi (OS: Raspbian) and Java (JDK-7-Armhf). My code wont execute without creating a Exception.
I'll been reading and trying several proposals and nothing have worked yet.
So now i am confused of what went wrong..?
So it goes like this:
I've got a Java source code that will run in my Eclipes IDE.
But when i export the .jar-file, even with library (JRE System lib. _86, JavaSE1.7, JAVAX.comm), as "Runnabel JAR" or just .JAR and execute it om my Raspberry pi, i've got "NoCLassDefFoundExecption: SerialPortEventListener..!
I just don't know why, it won't find the library and use it..!
On my Pi i have librxtx-java installed and JDK-7-oracle-armhf.
librxtx-java should be setting its JAVA_PATH on it's own when installed, but not sure that is done correct!
(I've got a folder /usr/jni and it contains: librxtxSerial.so and
/usr/lib/jvm/jdk-7-oracle-armhf/).
Looking at the library Javax.RXTXcomm in Eclipse, i've got RXTXcomm.jar, that contains SerialPortEventListener, so it is defininated i the .jar.
I'm thinking about, could it be, that there is a missing link between my Java JVM and linux serialport driver? My JRE is working in some way, because it will execute a code to readout HOSTNAME & IP-Adress.
So is there some one who knows how to fix this..?
This is a readout of Java Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/comm/SerialPortEventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Caused by: java.lang.ClassNotFoundException: javax.comm.SerialPortEventListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
A copy of my code. "SimpleRead.java" The original from java comm API samples
You have to change the reference from javax.comm to gnu.io in your source code.
Try following:
Switch to root and run the program you created
If that helps do following
sudo adduser username dialout
then log out and log in from all terminals and GUIs

How to use classpath in ubuntu terminal for executing java class?

I tried to execute CreateTextFileTest.class file with classpath in the terminal as the following:
java -classpath ..:"/home/fatih/NetBeansProjects/Unit17 - CreatingTextFile/src/unit17/unit17/creatingtextfile" CreateTextFileTest
My class files in this directory : /home/fatih/NetBeansProjects/Unit17 - CreatingTextFile/src/unit17/unit17/creatingtextfile .
I have 3 classes in the directory: AccountRecord.class , CreateTextFile.class, and CreateTextFileTest.class
But, when I executed the CreateTextFileTest from the terminal with the code above, an error occured like that:
Exception in thread "main" java.lang.NoClassDefFoundError: CreateTextFileTest (**wrong name**: unit17/creatingtextfile/CreateTextFileTest)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
As far as I understand because CreateTextFileTest.java uses two different classes, executing fails. How to handle this situation? How to run my java project? How to use classpath in this situation? Am I using wrongly?
The error message states that the package name declared in your compiled class doesn't match what the JVM was expecting given your classpath setup. The classpath should point to the directory from which your packages start, not the directory actually containing your .class files. Given your error message I believe that this should work:
java -classpath ..:"/home/fatih/NetBeansProjects/Unit17 - CreatingTextFile/src/unit17" unit17.creatingtextfile.CreateTextFileTest
Given the duplicate unit17 in your path I get the impression there's something else mixed up here. You'll get a better answer on Stack Overflow...

Java program executes in eclipse but not in terminal

I am using Eclipse with Eclipse Maven Plugin (m2e).
My java program compiles and run correctly from eclipse interface but I am unable to compile and run it from terminal.
My Eclipse Setting:
I am using two third party APIs, for which in eclipse build path I added
"/home/syed/workspace/FirstMaven/target/resources/fuse-jna-master/build/classes" (as external class folder)
"/home/syed/workspace/FirstMaven/target/resources/apache-jena-2.11.1/lib" (as external jars)
Package:
package org.organization.upesh.FirstMaven;
My Project path:
syed#ubuntu:~/workspace/FirstMaven$
Source Code Directory Path:
syed#ubuntu:~/workspace/FirstMaven/src/main/java/org/organization/upesh/FirstMaven$
Classes Directory:
syed#ubuntu:~/workspace/FirstMaven/target/classes/org/organization/upesh/FirstMaven$
When I try to execute myProgram via below command
syed#ubuntu:~/workspace/FirstMaven/target/classes$ java org.organization.upesh.FirstMaven.myProgram
it gives me these errors:
Exception in thread "main" java.lang.NoClassDefFoundError: net/fusejna/util/FuseFilesystemAdapterFull
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Caused by: java.lang.ClassNotFoundException: net.fusejna.util.FuseFilesystemAdapterFull
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 13 more
But my test program that do not use the third party API runs correctly via:
syed#ubuntu:~/workspace/FirstMaven/target/classes$ java org.organization.upesh.FirstMaven.test
I think myProgram is not executing because of the two APIs (class folder and jar folder) that I am using.
I have added path of class and jar folders of the APIs to /etc/environment (given below) and rested my computer, but still the same error
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/syed/workspace/FirstMaven/target/resources/apache-jena-2.11.1/lib:/home/syed/workspace/FirstMaven/target/resources/fuse-jna-master/build/classes"
Please guide me how to run my program correctly
JVM does not get libraries from PATH. It uses special environment variable CLASSPATH that can contain a list of directories or jar files separated by colon on Unix or semicolon on Windows.
So, just define CLASSPATH and put references to all your libraries there.
Aleternatively (and IMHO better) use command line switch -classpath (or its alias -cp) when running java:
java -cp mylib1.jar:mylib2.jar com.mycompany.Main

Unable to run Scala-Neo4j project from command line [duplicate]

This question already has answers here:
Building JAR that includes all its dependencies
(5 answers)
Closed 8 years ago.
I developed a Java project in which I wrote some Scala classes and some Java classes. I used Scala-Neo4j wrapper in the project to write Scala functions for inserting and retrieval of Neo4j nodes. I also wrote Thrift services in java in the project as I need to call these Scala functions from Php. Finally I extracted a jar file using Eclipse and I tried to run it from the command line and I got the following Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/scala/Neo4jWrapper
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
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 dum.Sad.main(Sad.scala)
at dum.ScalaRunner.main(ScalaRunner.java:7)
Caused by: java.lang.ClassNotFoundException: org.neo4j.scala.Neo4jWrapper
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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)
... 14 more
It works completely fine when I run the project from Eclipse. But, while running the jar file which I extracted from the project I get the Exception above. Where did i go wrong?
It seems your are not setting the classpath up properly. Try this:
scala -cp ./where/is/Neo4jWrapper/jar YourClass
Of course, replace ./where/is/Neo4jWrapper/jar with the path to the .jar. Notice that if you need to point to more than one jar or class directory you need to separate them with : if on Linux/Mac or ; if in Windows. And avoid spaces in the classpath.

Categories

Resources