ERROR EvoSuite - Fatal crash on main EvoSuite process - java

I'm getting the following error when I try to run EvoSuite. I even provided the complete path to jdk but still the error is not resolved. Please help me out.
C:\Users\XYZ\Documents\Tutorial_Stack>java -jar evosuite-1.0.6.jar -Dtools_jar_location="C:\Program Files\Java\jdk-11\lib"
[MASTER] 21:56:45.409 [main] ERROR EvoSuite - Fatal crash on main EvoSuite process. Class using seed 1541559405405. Configuration id : null
java.lang.RuntimeException: Did not manage to automatically find tools.jar. Use -Dtools_jar_location=<path> property
at org.evosuite.runtime.agent.ToolsJarLocator.getLoaderForToolsJar(ToolsJarLocator.java:105) ~[evosuite-1.0.6.jar:1.0.6]
at org.evosuite.classpath.ClassPathHacker.initializeToolJar(ClassPathHacker.java:58) ~[evosuite-1.0.6.jar:1.0.6]
at org.evosuite.EvoSuite.parseCommandLine(EvoSuite.java:156) ~[evosuite-1.0.6.jar:1.0.6]
at org.evosuite.EvoSuite.main(EvoSuite.java:302) ~[evosuite-1.0.6.jar:1.0.6]

I am not sure if Evosuite works with any other version of JDK except 8. The Evosuite beginner's tutorial states:
The first prerequisite for this tutorial is a working Java 8 JDK
installation and a command-line prompt, with java and javac on the
classpath.
To check if you are set up, fire up a terminal and try the following:
javac -version
If you have JDK installed, you will see an output similar to the following:
javac 1.8.0_51
Note: the last part of the version could be different
Another question: Are you using any IDE for this like IntelliJ or Eclipse? I had a similar problem and I resolved it by setting the module SDK to 1.8 on my IntelliJ project.

Related

IntelliJ IDEA doesn't start on Ubuntu after Change the boot Java runtime

Before, my IntelliJ ran well. But I used java 6 , so my project could not run with gradle.
I switched java to version 8 with the command sudo update-alternatives --config java .
I checked java -version was 1.8.0_312. It's OK, but in IntelliJ, the Java still had version 6. Then, I changed java version in IntelliJ with:
From the main menu, select Help | Find Action or press Ctrl+Shift+A.
Find and select the Choose Boot Java Runtime for the IDE action.
Select the desired runtime and click OK.
And restarted IntelliJ, which could not be opened again. I tried to remove and install it again as well as removing java and installing it again too, but neither did work.
When I run ./idea.sh, I get the following error:
OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.intellij.util.lang.PathClassLoader"). To use archived non-system classes, this property must not be set
Error: LinkageError occurred while loading main class com.intellij.idea.Main
java.lang.ExceptionInInitializerError: null
Now, I'm not even able to "change JRE in intelliJ" as suggested in the comments any more.
I've had the same issue working on windows.
When you check IntelliJ's log (idea.log file) you can find a entry for the change you've made with its 'reset' option.
For me it was: (emphasis is mine)
2022-08-08 09:47:47,906 [ 594730] WARN -
Downloader.RuntimeChooserPaths - Set custom boot runtime to:
C:\Data\Java\jdk-17.0.3.1 in the
C:\Users\username\AppData\Roaming\JetBrains\IntelliJIdea2021.3\idea64.exe.jdk.
On errors, please remove the .jdk file
You find the log files are stored at:
Linux: ~/.cache/JetBrains/IntelliJIdea2020.3/log
Windows: %LOCALAPPDATA%\JetBrains\IntelliJIdea2020.3\log
macOS: ~/Library/Logs/JetBrains/IntelliJIdea2020.3
Converting the comment by the author from May 2 at 4:22 to an answer.
The issue was resolved by changing the JRE path in this file: /.config/JetBrains/IntelliJIdea2022.1/idea.jdk

MacOS run java in terminal, got Error occurred during initialization of VM

I installed JDK in my Mac, I tried to run java in terminal, but got this error:
~ % java
Error occurred during initialization of VM
Unable to load native library:
I got /usr/bin/java when I run which java. I tried to add environment variable into .bash_profile and got /Library/Java/JavaVirtualMachines/jdk-16.0.1/Contents/Home when I run echo $JAVA_HOME. However I can run java code in IntelliJ, I think that's because IntelliJ is using some internal JDK. I'm trying to use Apache Kafka, also got Error occurred during initialization of VM. Anyone know what may cause this happens?
BTW, I have 6 different versions in my JavaVirtualMachines file...Not sure if that's related.

Error when running Java file through Intellij terminal

In Intellij IDEA, when I run a java file in the terminal or run a jar artifact, I get this error:
I have an up to date jdk and runtime enviroment installed on my computer, and I only have one runtime environment installed. Also, I do not have an issue with the actual compilation of the program, just the
"$java Program" command.
The error message is clear: You compiled the Java source with an newer Java version than your are using to execute it.
So your assumption that you have only one Java version installed cannot be correct. Are you aware that the IDE itself comes with a Java runtime?
Next time please post text as text, not a link to an image.

java.lang.UnsupportedClassVersionError when following tutorial

I'm trying to use Play! but I always get an error when trying to run a project: [error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
When I do java -version or javac -version, it confirms I'm using Java 8 by outputting 1.8.0_45. I don't understand why this error happens, the docs says I NEED java 8 for the latest Play! version, the project has a dependency to Play! 2.4.2.
I followed the documentation: installed activator, added it to the path, generated a new project form the template 'java-play-intro' but when i type activator in my project directory, I always get the error above. I tried to use the update-alternative command to use java 6 and then 7 but the error is exactly the same.
BUT when I use activator ui it works fine !
How is this possible? Am I always supposed to use the UI?
Most probably the script you are starting, uses the JAVA_HOME environment variable and not the JDK binaries that can be found on your PATH.

Could not find the main class running jar

I created a program in java using a tutorial from NetBeans, and it works great in Windows. However, when I attempt to run the same .jar in Linux (RedHat) I get the following exception:
Exception in thread "main" java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=my/numberaddition/NumberAdditionUI, offset=6
From running this command:
java -jar NumberAddition.jar
The output ends with:
Could not find the main class: my.numberaddition.NumberAdditionUI. Program will exit.
The source code for this example can be found here.
What am I missing?
Edit: Is there something I need to add for portability between operating systems?
Edit, answer: Thanks for the commenters who left possible duplicate links. From those and some further research I was able to determine that the JRE on the Linux environment was an older version (1.6) than the version I compiled the program in originally (1.7).
Check your Java version in your RedHat box.
java -version
The exception you are seeing is related to the JVM trying to run a bytecode that has been compiled with a later version of the JDK.
Update your Java version on RedHat by downloading it from Oracle or using yum to obtain a version of the JDK which is suitable with what you compiled.
Or rebuild your software on RedHat ;) if your code is not relying on later versions language enhancements.
From running this command:
java -jar NumberAddition.jar
The output ends with:
Could not find the main class: my.numberaddition.NumberAdditionUI.
Program will exit.
While executing jar with java -jar, main class need to be mentioned in manifest file or full path to the main class should be specified putting jar file in classpath
For eg: if my.numberaddition.MainClass is your main class ...
run as
java -cp NumberAddition.jar my.numberaddition.MainClass

Categories

Resources