java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 (unable to load class - php-java-bridge

Project details: PHP project which uses a JavaBridge to complete a task. My updates to this project have only been with the PHP files.
I have viewed numerous threads now. My compile version of Java is JDK1.6 and the java version running on my server is:
java version "1.6.0_30"
I am terribly frustrated for this works locally on my device but when I run it on the server it fails, the tomacat log provides the following:
java.lang.UnsupportedClassVersionError: com/nlrt/reportgenerator/ReportGenerator : Unsupported major.minor version 51.0 (unable to load class com.nlrt.reportgenerator.ReportGenerator)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2840)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1668)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at php.java.bridge.Util.classForName(Util.java:1518)
at php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445)
at php.java.bridge.Request.handleRequest(Request.java:458)
at php.java.bridge.Request.handleOneRequest(Request.java:510)
at php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202)
at php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250)
at php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)

It's a similar problem to this thread: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
What I would do is check and see if all of the java files are compiled with the same version. Version 51, according to that thread is J2SE 7. You need to make sure nothing depends on J2SE 7. It could be possible that the PHP-Java bridge was compiled with J2SE 7, and the rest was on JDK 1.6.

Resolved by using the original downloaded version of the JavaBridge that was already deployed and backed up. Unsure if the version I had downloaded locally was J2SE7 but nevertheless this bug went away. :)
Backups are always a lifesaver.

I had this problem with one my class file.
What I understood from this is, I build war file using java 7 and tomact was using java 6.
I simply changed to Java 7 :) Started working for me.

This was the same error while executing my project on server,But it right just by changing JDK6 to JDK7.0_51.

Related

Minecraft 1.12.2 modded server: "problem occured"

I have a minecraft modded server on 1.12.2, and it works for the most part, but it gives me an error.
The minecraft server is
forge-1.12.2-14.23.5.2846-universal.jar, and I'm on lubuntu, using openJDK 10.
I have these mods:
GalacticraftCore-4.0.2.236, GalacticraftPlanets-4.0.2.236, MicdoodleCore-4.0.2.236, and hopperducts 1.5
My system is:
Distributor ID: Ubuntu
Description: Ubuntu 19.04
Release: 19.04
I tried reinstalling it, and it worked to get mission libraries(some) and then this came up.
My code to run is:
java -Xmx1G -Xms1G -jar forge-1.12.2-14.23.5.2846-universal.jar
where "forge-1.12.2-14.23.5.2846-universal.jar" is the run file(yes, spelled correctly).
I just expected it to run, but it gave me this error:
A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)
at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
... 6 more
For posterity's sake, the issue is openjdk-10. The server .jar file uses something or other that isn't supported by versions of java after 8, and throws this same error you saw, that I spent a while chasing down. There's another relevant thread here. Solution: remove openjdk-10 (or whatever version you're using that isn't 8) with
sudo apt-get remove openjdk-10
and make sure version 8 is installed with
sudo apt-get install openjdk-8.
I found this on GitHub. Basically, the issue may be something with the vannilla Minecraft server.jar. Try re-downloading it, and manually renaming it. If that doesn't fix, there was a comment in there about Linux. Check that out.
Sorry I'm not more help. I'm not a Java developer, and I have just barely used Linux. I used CentOS a bit on my Raspberry Pi, and I used Ubuntu in a virtual machine, but besides that I'm a Windows user.

How to link Z3 build, Compiled for Java, from Eclipse Plugin?

I have a perfectly working Z3 Build system for Java. I want to call it from an Eclipse plugin. I tried several approaches, but non of them are working for me. These approaches are:
Adding Z3 build as an external class folder
How to Use External Class Files in an Eclipse Project
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
libz3java in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
com.microsoft.z3.Native.(Native.java:14) at
com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87) at
TestZ3.main(TestZ3.java:9)
Copied Z3 build to the Eclipse plugin, at the root. Then added com.microsoft.z3.jar under the Libraries (Right-mouth click on the project->Build Path->Configure Build Path->Libraries->Add Jars). The error is:
java.lang.UnsatisfiedLinkError: no libz3java in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
com.microsoft.z3.Native.(Native.java:14) at
com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87) at
plugintest.handlers.SampleHandler.execute(SampleHandler.java:37) at
org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at
org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at
org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
at
org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
at
org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at
org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at
org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
at
org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
at
org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at
org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:799)
at
org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:675)
at
org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:659)
at
org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:592)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362) at
org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113) at
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at
org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694) at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669) at
org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) at
org.eclipse.equinox.launcher.Main.run(Main.java:1515) at
org.eclipse.equinox.launcher.Main.main(Main.java:1488)
With or without the previous step, I added com.microsoft.z3.jar to Classpath, located at the Plugin.xml Runtime tab. In this case, the plugin is not finding the handler that is invoked after button press command.
!MESSAGE plugintest.handlers.SampleHandler cannot be found by
PluginTest_1.0.0.qualifier !STACK 0 java.lang.ClassNotFoundException:
plugintest.handlers.SampleHandler cannot be found by ....more
In fact, this approach worked for me a previous a installation (Dell, Intel, x64, Eclipse Mars (x64), Java 1.8 x64)!
Following the discussion in https://github.com/Z3Prover/z3/issues/1093, I configured Native Library Location of com.microsoft.z3.jar with the Z3 Build directory. Calling the Z3 Build from Eclipse plugin, the error reported is the same as in Approach 2, but calling it from a Java application, the error is more specific:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Users...TestZ33\build\libz3java.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.microsoft.z3.Native.(Native.java:14)
at com.microsoft.z3.Global.ToggleWarningMessages(Global.java:87)
at TestZ3.main(TestZ3.java:9)
Other https://www.chilkatsoft.com/java-loadlibrary-windows.asp
What is working is when you have a Java application under the Z3 build directory. Can anyone help how to use the Z3 build directory from a Java application, or from Eclipse plugin. By the way, I followed approach #2, was working fine until I try to replicate it (because my laptop crashed) and forced to use another laptop, then the same procedure is not working for me (I had luck, before). Right now, the new laptop has the following settings:
HP Laptop (AMD, x64)
C:\Users\nmd02\git\resa_mars_workspace>java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
PATH:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\QuickTime\QTSystem\;C:\Program
Files\MATLAB\2017a\runtime\win64;C:\Program
Files\Java\jdk1.8.0_144\bin;C:\Program Files\Git\cmd;C:\Program
Files\CMake\bin;C:\MinGW\bin;C:\python36;C:\Users...git\ninja;C:\Program
Files (x86)\Windows Kits\8.1\Windows Performance
Toolkit\;C:\gnuwin32\bin
I really appreciate for your help in advance.
Cheers,
/Nas
At runtime your code needs to find com.microsoft.z3.jar, libz3.dll/.so/.dylib, and libz3java.dll/.so/.dylib. Java takes care of the first one, but the operating system will have to find the other libraries, i.e., whatever environment your code runs in must be set up such that PATH (Windows), LD_LIBRARY_PATH (Linux), or DYLD_LIBRARY_PATH (OSX) point to the libraries. Also, make sure that your version of Z3 and your version of Java are both 32-bit or 64-bit, otherwise the error messages you get may not be very informative.
For some flavors of Java, it may also be necessary or helpful to provide the java.library.path setting to the JVM.

Jboss6EAP java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.registerResolvableDependency

I am moving a simple web application from Jboss 4.3 to Jboss 6 EAP (Jboss AS 7.2). However, I am unable to deploy the war because of the error
07:43:17,773 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 63) Context initialization failed: java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.registerResolvableDependency(Ljava/lang/Class;Ljava/lang/Object;)V
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:458) [spring-2.5.5.jar:2.5.5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:356) [spring-2.5.5.jar:2.5.5]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-2.5.5.jar:2.5.5]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-2.5.5.jar:2.5.5]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-2.5.5.jar:2.5.5]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.7.0_60]
at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_60]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_60]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
I am not sure what needs to be done. The Spring libraries the war file uses is version 2.5.5 and is bundled within the war 0 within the WEB-INF/lib directory.
Any help in resolving my problem, would be much appreciated. Thanks.
I was able to solve this issue. Would like to share with others, in case they run into the same issue. The war file we were using had Spring libraries and was included within the war file.
The problem was with the versions of the spring.jar and spring-context.jar. The former was 2.0.3 but the latter was version 2.5.5. I downgraded the spring-context.jar to 2.0.3 and it did the trick.
Not sure, why there was no problem in Jboss 4.3. Anyway, I don't have the problem now.
I would like to add that this problem could persist - after clearing out the dependencies (using exclusions), there could still be a wrong version in the Eclipse classpath.
You can figure this out running f.ex. a test with two methods:
in Eclipse
using Maven
mvn clean test -Dtest=com.example.HelloTest
Compare error messages / the stack traces, they might be different, or the Maven test runs fine while in Eclipse the test fails.

java.lang.UnsupportedClassVersionError: bad major version at offset=6

I have deployed a WAR file in the webapps folder in my tomcat. And when I am starting my tomcat, like below
C:\apache-tomcat-6.0.35\bin>startup.bat
Using CATALINA_BASE: "C:\apache-tomcat-6.0.35"
Using CATALINA_HOME: "C:\apache-tomcat-6.0.35"
Using CATALINA_TMPDIR: "C:\apache-tomcat-6.0.35\temp"
Using JRE_HOME: "C:\Program Files (x86)\IBM\RationalSDLC\Common\Java5.0\jre"
Using CLASSPATH: "C:\apache-tomcat-6.0.35\bin\bootstrap.jar"
I am getting this below exception-
SEVERE: Error deploying web application archive DirectoryServer.war
java.lang.UnsupportedClassVersionError: (com/services/rest/Listener) bad major version at offset=6 (unable to load class com.services.rest.Listener)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:73)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:56)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
And this is my JAVA version-
C:\apache-tomcat-6.0.35\bin>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
Can anyone provide any suggestion why is it happening?
You have essentially compiled your code with JDK 1.6 but running it with Java 5 - Just ensure a Java 6 runtime.
Even I faced same problem. The problem is inappropriate class version, for ex. compiling with different jre.
Solution: IF you are using Eclipse or RAD, set change compiler setting as per your requirement and also change same setting to project configuration by clicking on "Configure Project specific setting". Windows->Preferences->Compiler-> click on link "Configure Project specific setting".
For me the fix was to set the JAVA_Home system variable to the correct path.
It is a compiler issue. Make sure all your modules are configured with java 1.5 as a compiler. Window-->preference--> Java --> Compiler. Make sure 1.5 is selected.

(java)Could not find the main class

My code is compiled on OSX and it works fine(compiler version 1.6). But when I copy it to a remote ubuntu. I can not run it.
When I run
java TPCC.class
I got exception like this.(By the way TPCC.class is in default package)
Exception in thread "main" java.lang.NoClassDefFoundError: TPCC/class
Caused by: java.lang.ClassNotFoundException: TPCC.class
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TPCC.class. Program will exit.
And my java version on ubuntu:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
It's also 1.6 and I think it fits the compiled binary. How can I fix this problem?
The problem is in the way you run the program. Compiled java called
ClassName.java
will be ClassName.class. You should run it like
"java ClassName"
. You shouldn't run it as
"java ClassName.class"
What happens here is this. When you run it as java ClassName.class, JVM try to look for ClassName called "class" in the package called "ClassName" that does not exist. So it will throw NoClassDefFoundError.
This is an invocation problem as the error shows: java should be used and not the filename of the class.
The error message tries to say you this by stating that "TPCC/class" is not found.
(sorry for first adding comment, used the wrong field)
Specify the classpath when invoking java:
java -cp <path-to-jar> TPCC