Java VM version is invalid (TestNG) - java

I am working on an old java project that's still using Java 1.6 . I need to write some test suites for this project and wish to use TestNG for this purpose. However, on running the test I continuously get the error
VM version 1.6.0 is invalid, Java 1.7 or above is required for running TestNG.
I checked out the other similar questions but none of them answer my query. Downloading an old version of TestNG also doesn't work (I tried several 6.8.22 versions). I am using a mac.
Can someone please help me with this? Is it possible for me to define a different execution environment for testNG only? (so that the rest of the project runs Java 1.6 but testNG takes 1.8)
Any kind of help will be great. Thanks

Related

How to fix this version of the Java Runtime only recognizes class file versions up to 52.0 in jbpm

I created a custom process listener for my jbpm and deployed the jar in artifact and built and deployed in project setting and gave deployment.xml resolver type as reflection and package name . classname in identifier
i'm stuck with this error when i try to build and deploy the jar in the project please help me guys.
The error i'm facing
classes with v59 are emitted by javac v15 (or javac v16 and up, if using the --release 15 switch). A java that complains about class files being higher than v52 is java v8.
In other words, you've compiled code to class files targeted at java 15, and are trying to run these on a java 8, and obviously that square peg does not fit into that round hole.
You have 3 available solutions:
Upgrade the java to java15 or up. That'd be the java running in that cloud / workbench thing.
Downgrade the java you're compiling with back down to jdk8. If the class file was e.g. produced on your workmachine, either learn how you configure which java is the default target, or if using an IDE edit the project settings, or if you can't figure any of this out, just uninstall it all and ensure only a java8 is installed. Not recommended.
Configure the build script (and, depending on how you've set things up, your IDE configuration) that you want to target java8. If you're using javac on the command line, this boils down to adding a --release 8 option when compiling. Find the equivalent of that for maven, gradle, eclipse, intellij - whatever you are using.
Any one of these options will fix your problem. The list is exhaustive.
I had the same issue. I was creating the docker image with java 11 version and trying to deploy it with java 11 on Kubernetes using kubectl commands.
How I fixed it: I need to create the docker image again with java 8 version afterthat I moved this image to docker hub and deploy it on Kubernetes.

Running junit plugin test suite fails due to concurrent modification exception In arrayList.java

When I run my junit test suite I get failures but when I run them individually they all pass.
I run on Mac OSX El Capitan but other developers use Windows 7. When they run the same tests as we all contribute to the same repository, their tests pass without any problems. Does anyone know if there is a difference between the two operating systems that would cause a problem with my tests being run differently.
I am running eclipse Mars.1 with Oracle Java 7 and they are using Kepler and Mars with IBM java 7 and 8. Thanks for any input.
Normally, one gets that exception when they're are trying to modify the list they're iterating through. Maybe post your test class so that we can see

JAVA Compilation : compile with new JVM version and run on older version

Here is a small explanation of my problem.
I have an application which was compiled with java 1.5. This application is installed on 2000 pc (blockboxes) installed at customer premisses.
The jar of my application is often updated to add new feature and fixes, but for technical reasons, it is not very easy to update the java version, so I must keep using Java 1.5 on those existing machines.
Few months ago, I got a request for a new requirement for this application. To fulfil this task I have added the usage of Hazelcast in this application.
My problem if the following:
- Hazelacast jar file needs Java 1.6 or above, so I must compile my application with 1.6
- The new functionality using hazelcast will only be activated on demand by settings a new parameter. This means that it will not be used in the 2000 already installed blackboxes.
- All new blackboxes will be installed with Jave 1.6 or above to be able to use the Hazealcast functionality.
My problem is that I want to have a unique source code and unique version of my application for old blackboses using Java 1.5 and new blackboxes using 1.6 or above.
In the beginning, my idea was to always compile with version 1.5 and make sure that the new functionality would only be activated in blockboses using java 1.6 or above. This option is not working, because when I compile with 1.5, the compiler complains that Hazelcast jar file needs 1.6 :(
The second option would be to compile with 1.6, but then I cannot be sure that my application will still work properly on all blackboxes using 1.5. :(
I'm would like to know if someone here would know how to solve this kind of problem?
Just let me know if my explanation is not clear ;)
Thanks in advance for your help.
JVM is Backward compatible.You can run almost all code from Java 1 on Java 8.
So the best way is to use the option two. Compile it with 1.6 on some testing machines. And if it works( which most probably will) you don't have to make much change to the application .
You can compile your code to Java 1.5 bytecode using JDK 1.6, just take care of the following:
-source=1.5 and -target=1.5 compiler options
bootclasspath should point to rt.jar from JRE 1.5
See this post for more info: http://www.draconianoverlord.com/2014/04/01/jdk-compatibility.html
The post also recommends simply building your application with older JDK if possible. You need to figure out a different build process and exclude incompatible libraries from the classpath. If you use Maven, consider having two pom.xml files, with an optional parent file.

Need help on NoClassDefFound error

I'm working on a service to prepare spreadsheet for a report. I'm using jxl-2.4.2.jar to achieve this ( please note that I can't use the latest version due to compatibility constraints). When I execute the code locally on my eclipse it works fine. My eclipse has java 1.5.
When I deploy my code in my test environment, its giving NoClassdefFound error for jxl.* ( any classes in jxl ). My test environment has IBM's java 1.5. I believe it doesn't make any difference if I use IBM's version or Sun's version of java in this context.
I believe this error could happen when JVM fails to load the class at runtime or if the class has any static methods/properties. I checked the classes and none of them have static contents. So, this could be something else.
FYI.. I'm using ant to build the project & I check the build.xml. It is showing the correct version of java 1.5. Could someone please help to fix this error? Also Just FYI.. my project resides on AIX 5.0 server.
Any help in this regard much appreciated. Thanks in advance.
This error implies that your dependency is missing at runtime i.e. the set of dependent jars is not not correct.
jxl-2.4.2.jar is not getting shipped along with deployment, so just to resolve the issue , you can manually copy this jar in dependent lib folder of deployment.
But proper fix will be to get your ANT build checked.

bad version in class file

When I use certain jars in one of the connector projects i write for lombardi in TeamWorks eclipse i get a bad class version exception...
any ideas how this might be resolved..
Regards,
Adhir
You will get this error if you are using (say) Java 1.5 and you are using a JAR compiled with Java 1.6.
The easiest way to resolve is to upgrade your version of Java to the one used by the JAR.
Try to compile/recompile all your stuff with the same compiler.
Typically this happens when you have something compiled with a higher version and
you try to run it with an older one.
This problem can also be caused by an expired (365-day) Android certificate referenced by Eclipse.
See "Debug certificate expired" error in Eclipse Android plugins for details.
This is a result of running code compiled with a compiler version that is greater than the version of java you are using to run it. IE Code compiled with 1.6 and you are running it with 1.5. See this post to determine what version it was compiled with.
how-can-i-find-the-target-java-version-for-a-compiled-class
the easiest fix is to run it with the most recent JVM.
Root Cause for this error is that: jars including in your project is complied from other version of java and you are compiling your project from other version of java simply upgrading version of java will resolve this problem.
I also faced the same problem.

Categories