IntelliJ IDE (Community Version) doesn't support var declaration Java 10 - java

I've installed the version 2018.1 of IntelliJ IDEA (COMMUNITY EDITION), which added support for Java 10.
When I tried to use new "var" to type local variable, the IDE highlights it with red colour and the lovely phrase: "Cannot resolve the type "var". Please see attachment
varRed
I've read another post that happens exactly the same issue in which a member gave a possible solution https://stackoverflow.com/a/49719734/9478809
I've done that as well, I've created a live template for that type for Java statement but it still doesn't work.
Some of you got any suggestion for that?
I will appreciate your help
Thanks in advance.

To expand on nullpointer's comment, there are a few things you need to verify:
Make sure you've downloaded an updated SDK (version 10 or higher). I recommend using sdkman to install the SDK because it helps manage multiple versions. SDKMAN
Hit cmd; to open Project Structure
For Project SDK, select your updated java SDK
For Project language level, select the corresponding level
Now navigate to Modules, and make sure the correct language level is selected here too. I recommend selecting "Project default" to avoid future confusion.
As a troubleshooting step, it's also helpful to compile on the command line with maven or gradle to make sure it is an IDE configuration issue.

Related

IntelliJ IDEA: "cannot resolve symbol" for String, System and other Java classes

I recently downloaded IntelliJ IDEA to a different computer. On one computer it works fine on the other computer it is giving me this current issue.
When i open a new project with a template it automatically shows errors everywhere even though it allows the code to run and shows the output correctly: standard Java library classes like String and System are highlighted in red and the error tooltip says: "cannot resolve symbol".
I have tried "Invalidate caches/Restart", but it didn't help.
Check the JDK configuration Classpath tab in Project Structure | SDKs:
Also check that project and modules use the same JDK.
If it's empty, remove the JDK and add it again. It's not recommended to use JetBrains Runtime as your JDK, download and configure some different standalone JDK instead, 2020.1 version can download JDK for you.
Important notice
The bundled JRE is used for running the IDE itself,
and it's not sufficient for developing Java applications. Before you
start developing in Java, download and install a standalone JDK build.
I tried above, but no luck. I did get it working with File -> Invalidate Caches...
I selected all three checkboxes and then "Invalidate and Restart". That worked for me.
Often this means there is an issue with your java compiler. Normally this issue arises on an initial Intellij install. You can install/update the java compiler to get it working properly.
Go to the editor and type Ctrl + Alt + Shift + A . Then, a little bar pops down and you can select to either install the compiler, or configure it. Both times this happened to me, I just clicked install and once it was done, everything worked. If the install doesn't work, you can just reconfigure your compiler.
Removing the Java SDK and adding it back under File->Project Structure did it for me.
The only thing that worked for me (after hours of trying!) was to use the Android Studio's embedded JDK. "Invalidate caches/Restart" did not solve the issue, even using the same JDK version which was not coming with Android Studio was giving the Cannot resolve symbol 'String' errors. Wonder what's so special with this pre-packaged JDK! Hmmm
For me the solution seems to have been creating a new Run Configuration.
I had tried deleting the SDKs, and re-adding the one I needed but that did not clear the error. But creating a new Run Configuration did the trick.
I had this problem when I uninstalled JDK and re installed it, and when I was making a new project I had the uninstalled JDK file selected, which somehow caused the system to be in red and un run-able.

unable to see cucumber with java in plugins of IntelliJ IDEA

I'm new member for IntelliJ. I am trying to install a plugin for Cucumber in IntelliJ IDE.
Following are the steps which I am trying:
File > Settings (Ctrl+Alt+S)
From left hand pane, landing on Plugins tab.
In Search box, I am trying to search "Cucumber for Java".
But no result is displaying for same.
Can anyone help me on this ?
On search I am not able to see the option Cucumber for java, which is visible here in given stack.
Please see the documentation.
Use the Browse Repositories button.
Cucumber for Java plug-in is available out of the box in IntelliJ IDEA Ultimate.
For IntelliJ IDEA Community edition it's available as a free plug-in that you need to install:
In case IDE doesn't see the plugins list, please check the proxy settings. Disabling this option may also help.
It's also possible to download install plugins manually from disk. Make sure to get the version which is compatible with your IntelliJ IDEA build.
Cucumber for Java can be downloaded here.
The version compatible with IntelliJ IDEA 2018.1.x is available by this link.
Please also note that there is no Cucumber for Java plug-in version that is compatible with IntelliJ IDEA 2018.2 EAP builds at the moment. If you need this plug-in, please use 2018.1.4 release version.

IntelliJ IDEA 17 - ASM Bytecode Outline isn't working

I am using IntelliJ IDEA 2017.1.4 as my IDE. Recently I have found a plugin called ASM Bytecode Outline which is actually what I've dreamed of. I need such plugin so that I can convert Java code to ASM code or to bytecode easily.
I have installed the following plugin and restarted my IDE. Then I was expecting to be happy, however I was disappointed because the plugin seems not working:
Simply nothing.
I have tried the following:
Recompile and rebuild the project.
Restart IntelliJ.
Reinstall the plugin.
Restart my PC.
However, as you see me asking here now, you can guess that none from what I tried has worked, sadly. I clearly understand that the plugin might be pretty old and was not updated for years, but I still need at least something similar that can convert Java code to ASM-ready code, like:
.
Is there a way I can solve this, or is there any other similar solution (not required to be an IntelliJ plugin) for what I want?
I updated the plugin and now it works fine with newer versions of Intellij IDEA.
You can download it from here: https://plugins.jetbrains.com/plugin/10302-asm-bytecode-viewer
The source code can be found in here: https://github.com/elitegit/asm-intellij-plugin
It includes the latest version of ASM library as well.
You can use the plugin in 3 different ways:
Right click somewhere inside the code editor and choose "Show
Bytecode Viewer"
In the "Code" menu, choose "Show Bytecode
Viewer"
Right click on the java file in the Project window and
choose "Show Bytecode Viewer"
You can find the setting inside Settings => Tools => "Show Bytecode Viewer"
ASM Bytecode Outline isn't compatible with IntelliJ 2017.1.4. The last time this plugin was updated was September 2015. Here's a link to the plugin page on JetBrains' website: you can see that it stopped being compatible in IntelliJ 14.
Alternative
A built-in bytecode viewer has been available in IntelliJ for a while. Use the menu View -> Show Bytecode to view the bytecode for one of your classes. See this link for more details.

JavaFX on Android - Gradle can't find JDK

I'm trying to get JavaFX applications to run on Android by using the Dalvik JavaFX-Android SDK (provided by the JavaFX Android porting team). So I downloaded the samples provided by the JavaFX Android porting team and have been trying to run one of them on Android without much success.
Using Eclipse with the Gradle plugin I imported the "HelloWorldFxml" sample project. Then I ran the Gradle task "./gradlew androidInstall" on the project like the README file told me. But unfortunately the task cannot execute because Gradle cannot locate my JDK:
(source: forumbilder.se)
Even though my JAVA_HOME system variable is correctly set and I havn't had a problem with it before:
(source: forumbilder.se)
Anyone that can provide some insight as to how I can fix this?
Versions: Eclipse Luna Service Release 1a (4.4.1), Gradle 2.2, dalvik-sdk-8u40-ea3, Android SDK Build-tools 21.1.2, Android SDK Tools 24.0.2
Edit: The console output when running "gradlew androidinstall" on a sample project:
Even though the error message doesn't specify it, maybe it's looking for javac in your PATH? In case it's not in there try adding ;%JAVA_HOME%\bin to the end of your PATH variable (and restart Eclipse afterwards, I've had the problem of running processes not getting changes to environment variables before).
Check the Java setting in Eclipse:
Window -> Preferences
Java -> Installed JREs
Make sure that your JDK 1.8 is listed there. If it's not, add it using the Add... button.
Once the JDK is known to Eclipse, make sure that your project's settings use that JDK as a compiler, and the Gradle plugin should be able to pick up the setting from there.
In a pinch, you should also be able to run Gradle from the command line, and it should work fine since you already set the %JAVA_HOME% variable.
Basic Note
Since the release of dalvik-sdk-8u40-ea3, and in very short time, the JavaFXPorts team has released a few new versions, all of them simplifying all the process of porting a JavaFX application to Android or iOS.
They released dalvik-sdk-8u40-ea4 and they announced the release of a new plugin, that will simplify to the minimum the steps to create a mobile application from JavaFX.
While this answer may not help the OP in his particular problem, definitely it will help him and others, since everything is really simplified.
New approach
With this plugin, there's a new way of creating the HelloWorldFxml application for Android.
The new javafxmobile-plugin allows you to generate the apk with a single 'build.gradle' file.
You can find this an other basic samples here, and download the repository here.
You won't need to edit a single line, just type this on the command line, on the root of the sample, with your device connected:
gradlew androidInstall
As for previous releases, you will need JDK8u40 and Android SDK installed. No need for dalvik-sdk though, it's retrieved by the plugin.
Notice that you can open these samples from your IDE, so you will be able to modify them, and run them locally or build again the apk for your device.
Had this problem, too.
My proberties:
-Windows 7
-Dalvik SDK (dalvik-sdk-8u60-b5)
-JDK 8 (newest Version 8_60 / IMPORTANT: JDK not JRE)
-And I tried also the HelloAndroid project provided by the Dalvik-SDK-download.
So i execute the command line: gradlew installDebug
My probelm was nearly the same.
"Fail to find JDK. Please make sure there is a JAVA_HOME or JAVA8_HOME systemvariable."
#1
Created these proberties. Just like described in this post:
How to set java_home on Windows 7?
So to make everything sure, I created both with the same path. Cause I don't know exactly which one is used by gradle.
#2
This is really the hack that helps me out. Found this also in StackOverflow.
Write in your build.gradle under the android{..} stuff this line:
retrolambda {
jdk 'C:/Program Files/Java/jdk1.8.0_60' //<--your JDK-path
}
it looks like that
Then execute the same command line again and it worked for me.
I think only the 2. steps was the solution, cause I guess gradle don't look for the variable if there is a direct path to the jdk.

No source code is available for type java.util.Objects

I've run into a pretty weird problem.
I checked out a repo from github in eclipse. It's a gwt project. When I try to compile the project, I got an error:
No source code is available for type java.util.Objects.
There are also some similar errors which all point to the same problem: I use the wrong Java version.
What is weird here is that I do use Java 7 in my project.
I can not post an image here but I do use java7. I added a test class which contains some features in java7, like switch(String), it works fine when I run it as a Java application.
Got a clue? Need help!
Answer: Thanks to sᴜʀᴇsʜ ᴀᴛᴛᴀ, I got it right. I used gwt-2.5.1. Change it to 2.6, it works! Thank you guys.
That's because Eclipse couldn't find the java library.
Please check the project settings and source tab. and make sure that the java sdk was included.
If are you using GWT 2.6 , then below 2.6 versions of GWT doesn't support java7.
Java7 support added in GWT 2.6 version.
Make sure that the GWT version and Java version matching or not.
Just because you have java 7, doesn't mean you have the source for it.
Java code running in GWT is translated to Javascript, so some classes that work on a JVM won't work with GWT
Check the JRE system library in project build path.
Right click on project -> Build Path -> Libraries
Also check for the java compiler compliance level
Right on project -> Properties -> Java Compiler

Categories

Resources