Intellij IDEA: Unable to compile java code - intellij-idea

Whenever I try to compile/run a java code I get the following.
Compilation completed with 1 error and 0 warnings in 2 sec
1 error
0 warnings
java: Cannot find JDK '1.6' for module 'balh' <= ERROR
The SDK path is set and selected in "Project SDK"
I'm using IDEA 12 on RHEL 6.2
Thanks.

Ensure that your dependencies include Java 1.6 in that specific module.
Here, my module SDK is Java 1.7, but it's the same idea - if Java 1.6 doesn't appear or isn't available, either use the project SDK or find it on your box using the "New" dialog.

Related

Gradle sync fails when creating a new Kotlin project with default settings in freshly installed IntelliJ IDEA

I wanted to learn some Kotlin so I installed IntelliJ IDEA, created a new Kotlin project with the default settings and then the IDE tells me that Gradle sync has failed. Here's the error message:
Could not open init generic class cache for initialization script 'C:\Users\<my_name>\AppData\Local\Temp\wrapper_init.gradle' (C:\Users\<my_name>\.gradle\caches\6.8\scripts\344chmz69zyndatc9zp4rwux5).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
I googled the error and got a suggestion to try a different JDK version. Tried a few different versions but that didn't help. Then I installed the IDE on my laptop to see if that works and there I don't get any errors. As far as I can tell, the project settings were exactly the same on both machines but obviously something is messed up on my desktop computer. Both have Windows 10.
I'm also not at all familiar with the Java/Kotlin ecosystem or the build tools or whatever so I honestly have no idea how I could even begin fixing some Gradle errors. I don't really even know what Gradle is or what it does. So can you help me?
First, check the version which the project uses: File > Project Structure. Or, during project creation (https://i.stack.imgur.com/SXIzQ.png / example with SDK 1.8)
It has to be the same as JDK / SDK installed on your computer.
To verify java version installed in your terminal:
java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~19.10-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Error installing PMD on Eclipse Version: 2020-06 (4.16.0)

I recently upgraded to Eclipse Version: 2020-06 (4.16.0) on Windows 10.
My java version is "14.0.1" 2020-04-14
After the upgrade, I attempted to install Eclipse-PMD 2.0 from the Marketplace ( help / Eclipse Marketplace / etc. ) ...I receive the error(s):
Cannot complete the install because some dependencies are not
satisfiable Software being installed: a.jre.javase 14.0.0 Software
being installed: Eclipse PMD Plug-in 2.0.0.202006052026
(ch.acanda.eclipse.pmd.feature.feature.group 2.0.0.202006052026)
Cannot satisfy dependency:
From: Eclipse PMD Plug-in 2.0.0.202006052026 (ch.acanda.eclipse.pmd.feature.feature.group 2.0.0.202006052026)
To: org.eclipse.equinox.p2.iu; ch.acanda.eclipse.pmd.java.feature.feature.group
[2.0.0.202006052026,2.0.0.202006052026] Cannot satisfy dependency:
From: eclipse-pmd Java 2.0.0.202006052026 (ch.acanda.eclipse.pmd.java 2.0.0.202006052026)
To: osgi.ee; (&(osgi.ee=JavaSE)(version=11)) Cannot satisfy dependency:
From: eclipse-pmd Java Support (Optional, JDT Prerequisite) 2.0.0.202006052026 (ch.acanda.eclipse.pmd.java.feature.feature.group 2.0.0.202006052026)
To: org.eclipse.equinox.p2.iu; ch.acanda.eclipse.pmd.java [2.0.0.202006052026,2.0.0.202006052026]
Does anyone have an idea(s) as regards the source of the issue ...if all else fails I may try building the PMD source from the github repo ( https://github.com/eclipse-pmd/eclipse-pmd ) but I cannot imagine why this should be necessary.
I created eclipse-pmd and I can install eclipse-pmd 2.0 from the marketplace with Java 14 and Eclipse 2020-06 without any problems.
From the error message you provided it looks like there are two missing dependencies:
ch.acanda.eclipse.pmd.java requires (&(osgi.ee=JavaSE)(version=11))
several plugins require org.eclipse.equinox.p2.iu and ch.acanda.eclipse.pmd.java
The first issue indicates that you do not run Eclipse with Java 11+. Check the Java version by opening the "Installation Details" dialog: Help > About Eclipse IDE > Installation Details > Configuration. Then look for the system property java.version. If it shows a version lower than 11, then you need to configure Eclipse to run with Java 11+.
The second issue looks like a subsequent error. Since ch.acanda.eclipse.pmd.java couldn't be installed, all plugins that depend on this plugin cannot be installed either. Why org.eclipse.equinox.p2.iu is also mentioned in the error message is unclear to me since eclipse-pmd does not (directly) depend on this plugin and it should be a plugin installed by default in Eclipse.
If this does not fix your problem, then please open a new issue on Github as it is easier to help with problems like this on Github than on Stack Overflow.
You need to run Eclipse with a Java 11 JRE. This is normally done by insuring you have JAVA_HOME set to Java 11, and JAVA_HOME in your path. Alternatively, you can modify eclipse.ini and specify Java 11 as the vm (How to run Eclipse with different Java version?).

chirp-react-native run-android failing for Java 11 and 12?

Tried to build chirp-react-native with Java 12 and Java 11. Will not build.
If I drop down to Java 1.8 AND set my gradle distributionUrl to gradle-4.8-all.zip in chirp-react-native/android/gradle/wrapper/gradle-wrapper.properties, the package compiles and installs correctly and I think it runs correctly.
However if it's an easy fix I'd prefer to use a current JDK. Has anyone successfully built chirp-react-native using Java 12?
Steps to reproduce:
With Java 12 set in my JAVA_HOME env variable (/Library/Java/JavaVirtualMachines/jdk12-0.1.jdk)
react-native run-android fails with this error:
Could not determine Java version from 12.0.1
If I drop down to Java 11 as JAVA_HOME, I get a similar error message:
Could not determine Java version from 11.0.3
With Java 1.8 and Gradle 4.8, everything appears to build, install and run properly.
This comment describes the reason for this error - https://github.com/facebook/react-native/issues/22487#issuecomment-443759776
You might be able to upgrade the gradle version in the android/build.gradle file.
Can you try to run ./gradlew build from the command line and check for additional log messages in console? It might be that there are some missing dependencies required by your project. What is happening if you remove ChirpSDK from the project? Can you build it with Java 11/12 and without ChirpSDK?

How to resolve invalid source release error in intellij

I am using Intellij and I am trying to run a simple hello world android application. But i get the following error.
Error:java: invalid source release: 8
What could be the problem, any help?
Thanks in advance!
Android only supports java 7 so I assume that somewhere in your gradle/Intellij settings java 8 as source version is set. See this answer for more information: Which JDK version (Language Level) is required for Android Studio?

"Unsupported major.minor version 51.0" in Netbeans

I know that the title is almost identical to other questions, but, I've not been able to resolve my problem with those answers.
This is the problem:
I have 2 almost identical projects (one has been cloned from the other with mercurial) and some changes have been made.
After the last pull from the original project, the following error appears when I try to run the project. I know that means that the project is being compiled with java7 and run with java6.
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/[...]/Start : Unsupported major.minor version 51.0
The original project keeps running normally.
It runs if I change the Java Platform in the project properties to java7, but I need the project to run on java6, so that's not an option.
Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.6.0_35; Java HotSpot(TM) 64-Bit Server VM 20.10-b01
System: Linux version 3.2.0-32-generic running on amd64; UTF-8; en_US (nb)
Thanks for your help!
You can add more than 1 jdk to your environment and you can decide which one to use. try to add the jdk 6 and compile it based on that.