Compilation error Using jitWatch - java

I am not able to run jitwatch. It always returns me with compilation error.
Here is what I did:
git clone https://github.com/AdoptOpenJDK/jitwatch.git
mvn clean install exec:java
Has anyone ever found a similar problem?
How do we fix this ?

I've merged in the PR from Alex (thanks!) and that makes JITWatch build again under Java 1.7 which I intend to keep supporting.
I notice you have JDK 8 installed but maven didn't pick it up as it wasn't set as your %JAVA_HOME% environment variable.
FYI JITWatch has a Google Group here: https://groups.google.com/forum/#!forum/jitwatch where you can ask support queries directly.
Thanks for your interest in JITWatch.
Chris

It looks like this method was added in Java 1.8, and I suspect the command line compiler that you're using is using a 1.7 compatibility flag (and thus not able to see the method). Check to see if you're specifying a different version of Java with an environment variable that Maven is using instead, or running with the -verbose flag to find out what the Java version used is.
It looks like there's a Java 1.7 profile which is selected when the build thinks it's on a 1.7 runtime, and that might be a problem:
https://github.com/AdoptOpenJDK/jitwatch/blob/master/pom.xml#L108
So: check your Java version that's being used by Maven and investigate why it's not a Java 1.8 runtime.

Related

Java warning: [options] system modules path not set in conjunction with -source 11

This machine has had multiple version of Java JDK installed and multiple version of multiple IDEs (Netbeans, IntelliJ, Eclipse, etc.) Most recently, I have added JDK 15.0.2 and Netbeans 12.2. When trying to compile a simple "Hello World", this is the output that results:
ant -f C:\\Data\\NetBeans\\grading\\TestGrading -Dnb.internal.action.name=run.single -Djavac.includes=testgrading/HelloWorld.java -Drun.class=HelloWorld run-single
init:
Deleting: C:\Data\NetBeans\grading\TestGrading\build\built-jar.properties
deps-jar:
Updating property file: C:\Data\NetBeans\grading\TestGrading\build\built-jar.properties
Compiling 1 source file to C:\Data\NetBeans\grading\TestGrading\build\classes
**warning: [options] system modules path not set in conjunction with -source 11**
**1 warning**
compile-single:
run-single:
Hello World!
BUILD SUCCESSFUL (total time: 1 second)
As you can see, the file compiles and runs, but the warning is causing me concern. I have not been able to find a similar warning in my searches... (all of the warnings refer to "bootstrap class path not set" instead of "system modules path not set"
I have updated my Environment Variable to reflect the most current JDK with this entry:
JAVA_HOME=C:\Program Files\Java\jdk-15.0.2
What setting am I missing that wasn't properly updated as I've updated my JDK and my IDE? Or am I completely looking in the wrong places? Or do I need to fully uninstall previous versions and, if so, what will that do to previous code written using those previous versions that I'd still like to retain?
Thanks in advance!
I stumbled on the issue and the fix! While the new install changed the Java Platform in the Libraries properties to correctly point to JDK 15 as the new (Default), in the Sources area, towards the bottom, it left the Source/Binary Format still showing JDK 11. Changing this manually to JDK 15 made the warning go away. The warning message should have said something to the effect of "Source/Binary Format" does not match Library Java Platform - check corresponding versions."
It is sometimes happened because of java updates. When the newer version is needed,it says you to remove the older version. If you didn't do that this cause come confusing. You can better use older versions to solve this problem. Maybe this can help you.
I had this exact same warning, which in my case ended up as an error and caused build to fail when runnning mvn commands. I was using jdk 16 and also had 11 installed.
In my case, nothing has fixed it except to fully uninstall java from my mac and reinstall the versions I needed from https://adoptopenjdk.net/.
You need to update your JAVA_HOME environment variable.
On Mac update your ~/.bash_profile or ~/.zshrc. Make sure you have the version you want installed and make -v## the version you want to use. For example,
To use Java 11,
export JAVA_HOME=`/usr/libexec/java_home -v11`
To use Java 17,
export JAVA_HOME=`/usr/libexec/java_home -v17`
On Windows change you system environment variable to your new java version.
Heres how! (Confluence)

Can I have two versions of the JDK on my computer?

I'm trying to set the IntelliJ IDEA JDK to version 1.8 (because it's the latest). When I navigate to System/Library/Frameworks/JavaVM.framework IntelliJ IDEA shows 1.6. When I type java -version it shows 1.8. I found that command under "Finding default JDK on OSX" https://www.java.com/en/download/help/version_manual.xml
I'm confused what versions of the JDK I have... and where they are located. Appreciate any help.
Yes, you can. You have JDK 1.6 and 1.8 installed on your computer. According to the Jetbrains website, all their products require Apple JDK 1.6 to be installed in order to run on Mac.
To make IntelliJ IDEA use JDK 1.8, you will need to edit /Applications/<Product>.app/Contents/Info.plist file and change JVMVersion from 1.6* to 1.8* :
<key>JVMVersion</key>
<string>1.8*</string>
To start off java will usually uninstall any version of the JDK when you get an update. Secondly if you want to check to see what version you are running I would go into what ever you are using to program and see what version you are compiling under (For example netbeans or eclipse). If it says 1.8 that is what you are running and same for 1.6. If this is really becoming a super big problem all you have to is uninstall java then re install and it should fix it.
You can have many different versions of Java on your system. In general Java depends on environment variables and the PATH environment variable. Some programs and tools look for tool specific environment variables to allow you to use a specific version of Java for that particular tool.
In the case of IntellJ the link that Eddie B posted in his comment explains how IntellJ determines which "installation" of Java it should use.

Differenet java version than the one i set in environment variable

I'm new to all the Java stuff so sorry in advance if i ever mislead.
I have Eclipse Java EE IDE for Web Developers. Version: Juno Service Release 2 and i installed JBoss Hibernate tools extension. And while i was trying to add a configuration as in http://furqanlabs.blogspot.com/2013/01/hibernate-and-oracle-configuration.html this tutorial, i got such an error:
"Project DmisService has higher compiler option than running Eclipse. Hibernate plugins unable to load its classes. Please decrease the compiler option or run the Eclipse with higher JDK level."
So to know which JDK level my eclipse is using i did the followings:
i typed java -version on the comman line and i came up with the following result:
java version "1.8.0_11"
and when i checked my environment variable for JAVA_HOME it is C:\Program Files\Java\jdk1.6.0_30. and the Java Compiler setting is also 1.6 (as jre of the project as i understood) for my project.
So i came up with another questions -> Why command line gives me different java version than environment variable?
and my original question:
what exactly (i am also new the java terms) should i do to fix this problem?
Thank you very much for any suggestion.
edit: i also checked with eclipse: System.out.println(System.getProperty("java.version")); and it gives me 1.6.0_30
Adding Eclipse Java 8 Support helped me to resolve the issue!
Ref : Eclipse + Java 8 support?

What does javac -version show?

Even the official documentation of javac
says nothing about the -version option.
Javac -version tells you about the JDK version. That is, it gives the information of Compiler.
Official page does mention about it:
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
Why you cannot find on the page is, -version is not available for javac until Java 6 I believe (I am sure it is not available in 1.4 and before). That's why it is not showing on your page, which is javac ref page for Java 1.5. However, go to java command reference page of Java 1.5 and you should be able to find the -version switch.
This command outputs your java compiler's version. In mine case it shows 1.6.0
Just to expand, both display the same; the version of Java that the tools are part of.
You can ASSUME that what one reports, the other will automatically also report and so it is overkill to have the option in both. Until the moment you encounter a machine where there are multiple versions of Java installed and you can compile something yet you can't run it. Displaying the versions of javac and java can then quickly tell you that the setup of the machine is messed up enough that different versions of Java are being used to compile and run. And then you thank the designers for adding it in.
You are looking at the official documentation for an OBSOLETE version of javac Java 5. The -version option is documented in the javac manual entry for Java 6 and Java 7.
And in response to your question about what -version actually shows (for javac and java) the best answer is "unspecified" or "it depends on what version / platform you are using". In practice, your best bet is to just try it for yourself.
If your reason for asking is that you want to extract some useful information about the Java platform from the version strings ... I recently tried searching for a web page that listed the version strings for the java command, and came up empty. A better approach would probably be to write a tiny Java application to print out the relevant properties from the System properties object. The javadoc for System lists a number of properties that are standardised.

Setting up IntelliJ IDEA with Java 1.8/1.7 and resolve "java: System Java Compiler was not found in classpath"

Let's make the long story short. Here is what happened:
IntelliJ 12 CE downloaded and installed
Latest Java 1.7/1.8 downloaded and installed
JDK was setup to make and run the project
I faced the following strange error:
Error: java: System Java Compiler was not found in classpath
This was despite of the fact that I had Java 1.7/1.8 fully installed and had no problems working with it through the terminal.
The solution that fixed my problem was as follows:
In:
Project Settings > Compiler > Java Compiler
I changed the drop down Use compiler from Javac to Eclipse!
Non of the other solutions I found on the web was helpful. Hope this helps you my unknown fellow reader.
IMPORTANT: THIS HAD NOTHING TO DO WITH MY JAVA_HOME AS IT WAS SET CORRECTLY.
You need to set environment variable JAVA_HOME. The IDE will check that variable on startup.
And enter the path to the home dir of installed JDK. Once it started it should point to the JDK used to run IDE. In this case the new compiler will be available among compilers already configured. You can always configure any new compiler using IDE compiler settings.
i found that if you install vscode java plugin in your mac , IDEA will not work correctly.
so disable the java plugins in vscode.
Every thing gonna be alright

Categories

Resources