gradle doesn't work in Intellij - problems with JAVA_HOME - intellij-idea

I can run gradle from a command line to see its version.
I can run, compile and debug a grails app in IntelliJ (version 10.0 or version 10.2)
I installed the IntelliJ Gradle Plugin.
Whenever I try to do anything with gradle from within Intellij I get an error as follows:
Executing command: "tasks"
Failed to connect to gradle process for command 'tasks'
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0\jre
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
But in my environment I have JAVA_HOME set to the proper JDK in a different directory. Plus when I look in IntelliJ for the project, it also shows the JDK in the proper JDK location. I cannot find anything that attempts to point the JDK to the Intellij JRE location.
Any ideas please?

IntelliJ uses its own jre.
to force IntelliJ to use it, you need to set the environment variable IDEA_JDK to point to your JDK.
then simply restart intellij and gradle gui plugin should now work.

Man I had so much trouble with this as well, and I don't remember having this much trouble before. I think they changed something. Here are the incantations which got it working for me on Mac OS X 10.11.5, both with Java and Gradle on IntelliJ 2016.1
Here's the summary: install the latest Java JDK from Oracle, add the java_home value to $JAVA_HOME and set that value to $IDEA_HOME (IntelliJ's variable for defining which JDK to use), install gradle (optional) using homebrew, then define the project SDK in IntelliJ.
Here it is broken down from the very beginning of a clean install:
1. Download Java from Oracle's Download Page
2. Use homebrew to install gradle
IntelliJ ships with its own version of Gradle, so this is really optional, and is helpful if you want to use Gradle outside of IntelliJ.
`brew update && brew install gradle`
3. Set the env variables
Paste the following into ~/.profile. These values will work regardless of which version of java or gradle you have installed. Don't set the GRADLE_HOME if you didn't install the standalone gradle.
export JAVA_HOME=$(/usr/libexec/java_home)
export IDEA_JDK=$JAVA_HOME
export GRADLE_HOME=/usr/local/opt/gradle/libexec
4. Set the environment variable to occur at application launch so that IntelliJ sees is using OS X's launchctl program:
launchctl setenv JAVA_HOME $(/usr/libexec/java_home)
5. Define the project SDK
Use the project settings window in IntelliJ to define the project SDK (I don't see this option anywhere else in the global IntelliJ preferences window, this has to be done in the project settings).
6. Wait for the indexes to update, then close and re-open IntelliJ. You should now be able to build the program.

if you are using Intellij version 10.x you should not install any Plugin to run a gradle script.
All you have to do is to go to the Gradle setup (File -> Settings -> Gradle) and set the Gradle Home folder (the location of your Gradle installation, eg. C:\tools\gradle).
You should be able to select a Gradle build file and run it.

Point your JAVA_HOME to JDK, not to JRE.

I think this error might be caused by an install bug with IntelliJ IDEA. When I look at the installed folder referred to in the error message on my filesystem:
C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0\jre
I see the jre folder but then another jre folder beneath that one which contains the bin and lib folders of the jre:
jre
jre
bin
lib
I copied bin and lib up a level into the first jre folder, and that fixed this error for me.

Related

How to get jrebel, jetty, gradle and intellij idea working together

I have installed JRebel plugin for Intellij Idea and my project is running with Jetty gradle plugin.
I run my project with "Run with JRebel", project perfectly runs, but hot swap which i expected is not working.
Does anybody have an understandable and detailed instruction how to set up Jrebel for work with jetty, gradle and intellij idea?
1) You need to add JRebel Agent as a vm argument into Jetty.
Depending on your environment:
Windows 64-bit JDK jrebel64.dll
Windows 32-bit JDK jrebel32.dll
Mac OS X 64-bit JDK libjrebel64.dylib
Mac OS X 32-bit JDK libjrebel32.dylib
Linux 64-bit JDK libjrebel64.so
Linux 32-bit JDK libjrebel32.so
You need to add -agenthpath argument in gradle.properties file:
org.gradle.jvmargs=-agentpath:[c:\path\to\]lib\jrebel64.dll
2) You need to generate rebel.xml files for your projects in JRebel IDE plugin
Right-click on the project node in the Project View and select JRebel > rebel.xml. Alternatively, you can check projet in JRebel Modules window
3) You need to deploy(run) your projects into the Jetty with rebel.xml configuration files and when you make a code change in a .java file you need to generate new .class file. IntelliJ IDEA does not compile classes on save by default. Press Ctrl+Shift+F9 to compile the current file, module or package (you can also find this command via Build > Make Project).

How to run a newly built Intellij-Community version, Run command is currently disabled

I just built a Intellij-Community version of Intellij, but run command is disabled. I believe I need a configuration file in order for the run command to be enabled. According to the documentation at Checkout and Build Community
To run the code, use the IDEA shared run configuration provided by the project.
Where is this file?, doesn't seem to be available in run ~ edit configuration. or how can I create one?
The readme file has configuration details that compile Intellij-Community correctly. Both JDK 1.6 and 1.8 are used. This then allows you to see IDEA run configuration file.
Configure a JSDK named "IDEA jdk" (case sensitive), pointing to an installation of JDK 1.6.
Unless you're running on a Mac with an Apple JDK, add /lib/tools.jar to the set of "IDEA jdk" jars.
Configure a JSDK named "1.8", pointing to an installation of JDK 1.8.
Add /lib/tools.jar to the set of "1.8" jars.
Run->Edit Configurations and then tell IntelliJ what kind of application you want to run:

Compile Erlang in Intellij

I try compile erl files in Intellij with Erlang plugin. Everything is good with compilation but in out/production the folder does not create any files .beam and when I run console I get message:
exception error: undefined function.
When I use c("file"). everything is all right. Why does Intellij not create .beam files?
Try to fix it by going to Preferences -> Build, Execution, Deployment -> Erlang Compiler and check "Compile project with rebar".
Also, verify that rebar is installed and configured in IntelliJ by going to Preferences -> Other Settings -> Erlang External Tools and specifying the path to the rebar installation.
I was having the same issue ..
The problem is very strange erlang plugin doesn't compile and copy the files to out directories meanwhile if you compiled from terminal or command prompt (windows) it is working fine. this issue arose after installing IntelliJ Idea v 15.
What I have done here to fix the issue:
Uninstall Intellij Idea v 15
Downgrade IntelliJ Idead to version 14.1.4
Install Intellij Idea again (v. 0.5.11)
Configure SDK to reference src of erlang language.
Create a new test project and start making the project again .. it should work fine...
Hope this helps you

SBT project refresh failing in IntelliJ IDEA with "Access is denied" error

I have recently migrated a Scala project over to IntelliJ IDEA (v13.1.4) from Eclipse, and I'm seeing an unusual error when I start IDEA:
SBT 'myproject' project refresh failed:
Error: Cannot run program "C:/Program Files/Java/jdk1.8.0" (in directory "C:\src\myproject"): CreateProcess error=5, Access is denied
CreateProcess error=5, Access is denied
Everything seems to work OK otherwise, and I have no problems executing SBT manually from the command line.
I'm running the idea64.exe executable on Windows 7 Professional 64-bit, with a Java 8 64-bit JDK that is installed in C:\Program Files\Java\jdk1.8.0.
I have also configured the IDEA_JDK_64 environment variable to point to this Java 8 JDK (with the value C:\Progra~1\Java\jdk1.8.0, so that it contains no spaces); JAVA_HOME is set to the same value, and the JDK is also included on my Path (as %JAVA_HOME%\bin). The project itself is configured to use the same Java 8 JDK.
However, the error appears to indicate that IDEA is trying to execute the jdk1.8.0 directory, rather than a program within the JDK installation.
Any suggestions for why I'm seeing this error?
As you might know, I think it is a bug of Scala Plugin.
This bug has been fixed already.
https://youtrack.jetbrains.com/issue/SCL-7481

How do I change the JVM used to run IntelliJ on Windows

I have two Java JDKs installed on my workstation, with jdk1.6.0_41 in my path, and jdk1.7.0_21 available as well, but not in the path.
How can I configure IntelliJ IDEA 13 to use a particular JVM? To be clear, I want to set the JVM used to run IntelliJ itself, not the SDK used for running my code. I am running Windows 7 Enterprise Edition and launch IntelliJ 13.0.2 by running idea64.exe
I have set JAVA_HOME to point to jdk1.7.0_21 but according to the About box it is using jdk1.6.0_41.
This FAQ on the JetBrains web site describes how to do this for Mac, but not for Windows.
This answer suggests using the IDEA_JVM environment variable for Ubuntu 12, but I have tried that and it isn't working.
I suspect you have another setting that is overriding your JAVA_HOME
From Jetbrains docs:
idea64.exe uses this JDK search sequence:
IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
With newer versions the environment variables are ignored. Instead there is a new action "Choose Boot Java Runtime". The easiest way to get to it is via "Find Action" Ctrl+Shift+A.
You can also edit the setting via the .jdk file in your user configuration directory, e.g. %APPDATA%\JetBrains\IntelliJIdea2021.3\idea64.exe.jdk. This is a plain text file containing only the path to the JDK.
It is not recommended to do this, and you should use the JDK that is bundled with IDEA.
CTRL+ALT+SHIFT+S to go to Project Structure
Under Platform Settings, go to SDKs.
Use the + green icon to add a new SDK and set it to that one.