umlgraph error, Could not find the main class - java

Folks, trying to automatically generate UML diagrams from code to speed up the discovery process. I've come across a project that does exactly what we need, http://www.umlgraph.org/doc/indexw.html
After the installation, I get the following:
umlgraph test png
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/umlgraph/doclet/UmlGraph : 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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.umlgraph.doclet.UmlGraph. Program will exit.
Java version on the system:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.11.90) (rhel-1.62.1.11.11.90.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Can someone please point me in the correct direction? Does anyone use a similar project? Thanks!

It looks like umlgraph 5.6_6.1-SNAPSHOT was compiled for Java 7 only. Here's a snapshot from it's build.xml:
<javac srcdir="${src}" destdir="${build}" debug="true" deprecation="true" >
<compilerarg value="-Xlint"/>
</javac>
No "target" attribute set explicitly, so platform java version is used. And from JAR manifest it's obvoius, that it was compiled on java 1.7
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0_21-b11 (Oracle Corporation)
So you can either install Java 7 to run umlgraph, or use the older version of ulmgraph, which was compiled to be compartible with Java 6.

Related

Can't run JAR files because of outdated JRE but updating it does nothing

I tried to open the jar with "java -jar blah.jar".
this is the outcome:
java -jar Desktop/lambertone2.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: main/Main has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56) .
I went to Oracle site to download the latest JRE but it doesn't change anything.
All this happened some day ago where the update section of java told me to erase java because it was obsolete, so i removed it and reinstalled it.
if i use the command java --version it says me that the command is unsupported.
if i use javac --version it says that it is version 10.

maven version exception on mac

When I execute "mvn --version" I get this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.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 org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Maven version I installed is maven 3.3.3
My java version is:
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
echo $PATH returns:
/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
How to solve the problem of Maven?
$JAVA_HOME should be pointing to 1.8.0_65 as in your case.
If you want it to permanently change the value of JAVA_HOME, you will have to add the command to your ~/.profile file. Below are instructions on how to accomplish this instead:
Open up Terminal.app (Applications → Utilities → Terminal)
Type:
emacs .profile
Add this to the end of the .profile file:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
export JAVA_HOME;
Note that JAVA_HOME should be the path of your JDK directory.
Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)
Open a new Terminal window (cmd-n) and type:
$JAVA_HOME/bin/java -version

mac-osx 10.9.4 Hadoop 2.7.1 Exception in thread "main" java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0

When trying to run namenode -format, I am getting below error. Can anyone please suggest how to resolve it? ( On mac os x 10.9.4 version. Hadoop 2.7.1 version)
Pro:hadoop-2.7.1 hadoop$ bin/hdfs namenode -format
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hdfs/server/namenode/NameNode : Unsupported major.minor version 51.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)
Java Version is as below...
Pro:hadoop-2.7.1 hadoop$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
In hadoop-env.sh path given as
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
51 Major version of Java class file format conforms to Java 7.
The Hadoop library in your version require Java 7, but you try to run it on Java 6 runtime which will not work.

Classpath for ojdbc6.jar not detected after being added to .bashrc in ubuntu

i have added the ojdbc6.jar and the ojdbc6_g.jar file in the .bashrc but i keep getting the driver error:
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
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 java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at jdbcdisplay.main(jdbcdisplay.java:17)
I have added the following Classpath to the .bashrc file for the ojdbc6.jar file:
export CLASSPATH=".:/home/shawnreese/Downloads/ojdbc6.jar:/home/shawnreese/Downloads/ojdbc6_g(1).jar"
The jar files are not even detected.They just keep showing the same error.On performing echo ${CLASSPATH} i get the jar file of opencsv.jar added in .bashrc.
.:/home/shawnreese/Downloads/opencsv-2.3/deploy/opencsv-2.3.jar
I am using java version:
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
and Oracle 11g Release 2.

Java can't find existing method in a class

I have jar archive build with Ant 1.9.1
When I launch class from it I get the following exception:
Caused by Java exception: java.lang.NoSuchMethodError: com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z)V
at com.blablabla.kats.drivers.CheckBox.check(CheckBox.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.blablabla.kats.utils.Operation.doInvoke(Operation.java:142)
at com.blablabla.kats.utils.Operation.invokeMethod(Operation.java:117)
at com.blablabla.kats.model.handles.ElementOperationHandle.invokeOn(ElementOperationHandle.java:33)
at com.blablabla.kats.model.statements.DirectAction.execute(DirectAction.java:45)
at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
at com.blablabla.kats.model.Procedure.call(Procedure.java:46)
at com.blablabla.kats.model.statements.Invocation.execute(Invocation.java:48)
at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
at com.blablabla.kats.model.TestCase.execute(TestCase.java:41)
at com.blablabla.kats.model.TestSuite.execute(TestSuite.java:45)
at com.blablabla.kats.model.TestProgram.execute(TestProgram.java:40)
at com.blablabla.kats.Main.main(Main.java:158)
When I compile "com.blablabla.kats.drivers.CheckBox" class by javac and replace corresponding file in jar all works fine.
I use htmlunit 2.12
java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
corresponding Ant task:
<path id="classpath.libraries">
<fileset dir="${basedir}/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile">
<javac srcdir="${basedir}/src/java" destdir="classes" debug="true" source="1.5" target="1.5">
<classpath refid="classpath.libraries" />
</javac>
</target>
${basedir}/lib contains a lot of jars.
The main are
kats.jar - my project, containing com.blablabla.kats.drivers.CheckBox
htmlunit-2.12.jar - where com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z) is.
Why it can happen?
The only difference that i see is, you are using 1.5 in ant script where as looking at the java version you are using java6 to run it. I am not sure if this may make a big difference as it should be backward compatible, but still give it a try. Change this version to 1.6 in ant build.xml
I found out that I didn't delete old compiled class.
When I cleaned up compiled classes all worked fine.

Categories