Gradle JAVA_HOME path in eclipse - java

I have a problem running Gradle project in eclipse Neon.2.
I find out that there is a problem with JDK path.
Somehow my gradle in elipse always use some strange JRE as a Java Home, when it should use a path to a JDK. I double checked my settings in eclipse and system variables, but still i cant find the solution.
I searched for answers and find out that people suggested changing Gradle settings in elipse.
I did all the settings but it still doesnt work.
All the settings
Btw, if I manualy set the Java Home while creating Gradle project it all works fine. But it has to work on other computers so I cant really use that solution.
That works fine

Create/update gradle.properties in GRADLE_USER_HOME ( C:\users\<user>/.gradle or linux ~/.gradle) with
org.gradle.java.home=<path to jdk>

In Preference of Eclipse (main menu: Window -> Preferences), select
Gradle -> Arguments -> Java Home, select "Workspace JRE".
Then select one of your jdk in your workspace.

Related

How do I tell IntelliJ about groovy installed with brew on OSX

I'm running:
IntelliJ Ultimate 2016.3
Homebrew 1.1.2
OS X 10.11.5 El Capitan
I ran brew install groovy which resulted in groovy being installed in /usr/local/Cellar/groovy/2.4.7/. Brew also added a symlink: /usr/local/bin/groovy -> ../Cellar/groovy/2.4.7/bin/groovy
When I open the groovy project in IntelliJ, it gives me an option to Configure a Groovy SDK. I haven't set this up yet, so I get a "Create" button, which launches finder. From what I can tell there's nothing that I can select to make IntelliJ happy. I've tried /user/local/bin/groovy, /user/local/Cellar/groovy, /user/local/Cellar/groovy/2.4.7, /user/local/Cellar/groovy/2.4.7/bin etc. No mater which I choose, IntelliJ doesn't accept the library and continues to tell me "Error: library is not specified".
Does anyone know how I'm supposed to go about telling IntelliJ where groovy is?
Install groovysdk:
brew remove groovy
brew install groovysdk
Set GROOVY_HOME, otherwise Intellij reports as broken installation:
export GROOVY_HOME=/usr/local/opt/groovy/libexec
Point IntelliJ to the installed directory, e.g.:
/usr/local/Cellar/groovysdk/2.4.7/libexec
brew install groovysdk
Right-Click on Project Root Folder or if a Config Wizard Pops up at the top of your windows we can click that link.
Select Add Project Framework Support
Scroll down and select Groovy
If it does not show in the list; it's because it already has the framework added.
If Groovy has not been added to IntellJ then Select Create...
browse /usr/local/Cellar/groovysdk//libexec/ e.g: /usr/local/Cellar/groovysdk/2.4.11/libexec/
Gotcha - It does show file browser that does not let you view your /usr/local file path, you need to press shift + command + g will open a dialog where you can type the path of any folder that you want to open
Done.
/usr/local/opt/groovy/libexec.
use brew info groovy to print help:
==> Caveats
You should set GROOVY_HOME:
export GROOVY_HOME=/usr/local/opt/groovy/libexec
I did this with Intellij IDEA 2016.3 on OS X.
I am able to configure this under Project Settings -> Global Libraries.
Add a new global library by clicking the + and select Java
Navigate to the location homebrew installed Groovy, /usr/local/Cellar/groovy/2.4.7 and select all the JAR files in the libexec/lib directory.
Set the name to groovy-2.4.7, or whatever works for you.
It is very easy to do:
Install groovy:
brew install groovy
Point IntelliJ to the following directory:
/usr/local/Cellar/groovysdk/<version>/libexec
You will see that intellij will get all the required dependencies
Because I could not select /usr in the open dialog, I used to 'go to folder' function of finder and created a favorite entry for /usr/local/opt/groovy/libexec
which worked.

IntelliJ Generated Ant build results in broken code

I added JDK and Ant to Enviroment System variables but that doesn't stop a simple Ant build in IntelliJ from breaking. I have set the system path variable to accept both Ant's directory and the JDK enviroment. I have created JAVA_HOME and Java is still functioning in the cmd.
There isn't any code in the project. There is just this build that generates this default code.
I haven't altered anything once I started the build and if I go into Project Structure -> Project Settings, I have the Project SDK set to 1.8.
What is going on here?
**EDIT: I managed to remove a lot of the errors by toggling a box to Generate the Ant Build to Use current IDEA instane for idea.home property. **
It looks like many properties from test3.xml are not available/defined in module_test3.xml. Did you already try to do a "Generate single-file ant build" (the second radio button in the "Generate Ant Build" dialog)? This could be a way to avoid the problem of Ant properties from one build file not being available in another build file.
Are you very attached to Ant for building your projects? You could give Gradle and/or Maven a try, to see if these tools work better for you.
If you are doing Android development, you could also check out Android Studio. If you are using IntelliJ IDEA, I would definitively consider upgrading to version 15; the community edition is free and version 10.5 is around four years old now.

Android Studio - supplied javaHome is not a valid folder

I decided to update my JDK to Java 8, and installed to the default location of C:\Program Files\Java\jdk1.8.0 with a jre subdirectory.
I wasn't sure how Android Studio worked out the JDK location, so I decided to launch it and see. I got the following message:
Failed to complete Gradle execution.
Cause:
Supplied javaHome is not a valid folder. You supplied: C:\Program Files\Java\jdk1.7.0_45
I updated my JAVA_HOME environment variable (both for system and user) to point to the new path, and tried adding it to my PATH variable as well, but every time I attempt to build in Android Studio I get the same message. The quoted path is nowhere to be found in my environment variables though, so where is it getting it from and how can I change it?
Thanks
The problem was my project's JDK location. From the Android Studio Project tool window, I right clicked on the root directory, selected 'module settings', and set the JDK location. Everything's fine now.
I don't know why or how this problem occurred but this answer got me over the hump. On macOS rm -rf ~/.gradle to wipe out the cache then restart Android Studio. I tried everything else up to and including reinstalling the JDK and Android Studio. Wiping out the .gradle directory is the only thing that worked.
Try to delete all .iml files and .idea, and re-import the project from Gradle. Worked for me (provided you have everything else set up).
This error happens when you switch from Intellij to Android Studio, or the other way around, and load the same project. Looks like their project model is not compatible.
For Android Studio 1.1.0, after right-clicking on the project:
Select Open Module Settings
Select SDK Location at top left
Type text into JDK Location: box
I ran into the same issue. My jdk was upgraded from a 1.8.0_172 to 1.8.0_202. And I kept getting the mentioned error although I changed to the right jdk, in the module configurations. What confused me was the fact that the API version was stamped with the old *_172 version in the dropdown of available project sdk's. I found the reason for this to be an old obsolete entry in the dropdown that referenced the old *172. After deleting this entry, the APi versions was magically stamped with the new version.
Note to self: Remember to sanitize your projects when new versions come along
I was also seeing this same problem. For me the fix was in 'Run/Debug Configurations' (Run > Edit Configurations...)
The 'Gradle project' value was set to the build.gradle file location, and this should've been set to the Gradle project object in IDEA, click the folder looking icon not the '...'.
I'm in 1.0.2 and after I clicked OK, it immediately opened a dialog to allow me to specify the location for my project, no longer requiring navigation of the menus to edit the project JDK path.
Definitely strange that during install, it says the JAVA_HOME environment variable is set to a path that doesn't contain the JDK. After spending time fixing it (downloading the full 64 bit JDK), I create my first project and get the same thing. Because it's not using the environment variable that it hinges on during setup.
Odd behavior.
For some reason I failed using all the above answers, so what I did is to delete (actually moved, so that I could go back in case something goes wrong) the ".idea" folder from the project. Then I opened the IDE again, and it went fine.
Getting this in 2021? Try to to rm -rf ~/.gradle and restart Android studio.

Specified VM install not found: type Standard VM, name jre7

Specified VM install not found: type Standard VM, name jre7
Have you ever encountered this problem in Eclipse while building an ant file? Then this article is for you. Deleting and recreating the workspace is not the solution. There is an easy solution to fix this issue without recreating the workspace.
Right Click on build.xml
Go to "Run As" >> "External Tools Configurations..."
It shall open new window
Go to JRE tab
Select proper JRE if missing (sometimes jre tabs shows error mark on that.)
For more technical details or issue similar to this find my blog here.
In my case it happen as I have changed my JRE.
Solution :
Right click on your ant script > Run as > External tool configurations... > Go to JRE tab > select JRE
Hope this help.
Thanks,
Sagar Vyas
Best answer found at
It happened for me after Un-installing Java and installing new version.
All I have to do is in eclipse open Installed JREs from
Windows --> Preferences --> Java --> Installed JREs
Then Add new JRE information. Details can be found here
This is a preferred way tell projects which JDK container to use, especially true if two or more devs are using the same version controlled eclipse project folder.
Window/Preferences/Java/Installed JREs
List one or more JDKs installed on your computer. Eclipse defaults name to jdk1.X.X_XX you should keep it as is. Never link project build settings directly to use these names.
Window/Preferences/Java/Installed JREs/Execution Environments
List of common jvm environments such as JavaSE-1.6 and JavaSE-1-7 names. Click rows and choose jre instance on the right side panel. These names are common and all team members should already have them in Eclipse installation.
Step 1: This is where you may accidentally have nothing chosen if JREs were uninstalled or names changed in InstalledJREs setting. You may get
Specified vm install not found error dialog.
Step 2: Choose 2nd mouse on build.xml file/Run As/Ant Build... popup menu entry. Click on JRE tab and choose execution environment. This may have obsolete value from the previous jdk values.
Project Properties/Java Build Path/Libraries
Add Library.../JRE System Library/(x)Execution environment
Choose execution environment to be used for this project. Team members may not have exact _XX jdk build but they can use the same version controlled eclipse project settings. Execution environment mapping hides user specific details.
Just had this issue & the solution above does not work, atleast not for me.
Instead I went the solution provided here:http://www.javaworkspace.com/VMNotFound.do
Essentially you go to the directory C:\projects\WORKSPACE.metadata.plugins\org.eclipse.debug.core.launches
In there search for the string of the JDK that that eclipse is moaining about & change it to the name of your installed JDK that you want to use that eclipse knows about.
You can change what JRE the ant bulid file is launched with inside eclipse.
Right click on the ant file in the ant view and select "Run As"->"Ant..." from the context menu.
Then in the launch dialog select the JRE tab. Note the error message at the top if it can't find the JRE that it expects.
Select a JRE that you have installed or manage install a new one. You can also add vm arguments (enable logging or change memory alocation) if you need to in this dialog.
Just delete the below file
"<Your eclipse workspace location>\.metadata\.plugins\org.eclipse.debug.core\.launches\<projectname>.xml.launch"
link to post
The last answer is absolutely correct, however a fast track way is to delete the project reference from eclipse (make sure to keep unchecked delete source) and import your project folder again. This way the project configurations are reset by eclipse using the new jdk.
But a wonderful post it did help me.
After Java update ant build failed and the below steps fixed it .
Right Click on build.xml-Run As-External Tools
Go to JRE tab and check the box to use the JRE same as workspace.
Removed below file and build maven project again, worked for me.
.metadata.plugins\org.eclipse.debug.core.launches\.xml.launch"
(ant file)Run As--> External Tool Configuations,
go to JRE tab and choose JRE

implicit super constructor object() is undefined. must explicitly invoke another constructor

Is this a new bug? I got a new mac computer and install eclipse on it. The checksum matches fine. But when I try to create a simple class, just for basic testing, I get the error mentioned in the title. Never before have I seen java complaining about object() constructor. Here is the class:
package com.my.ok;
public class First {
}
EDIT:
I am finding that the problem happens if I set execution environment to javaSE-1.7
This problem occurs if your JRE is not configured in project built path.
To configure JRE:
In Eclipse:
Right click on your project and select Build Path -> Configure Build Path
Go to Libraries tab click Add Library.
Select JRE System Library click Next
Then select JRE from options as per your requirement. Click Finish
In Netbeans:
Right Click on the Project and select Properties.
In the Library category select Java Platform as per your requirement.
Then go to Source category select Source/Binary Format and select JDK as per your requirement.
Explanation:
The error was because you did not include System libraries in your project and your class was not able to find Object() constructor which is called first in the hierarchy when you create an object.
Example:
package com.my.ok;
public class First {
}
what happens is compiler extends by default your First class to Object class
package com.my.ok;
public class First extends Object {
}
but Object class was not found in your case and you were getting this error.
This is a typical issue with JRE configuration in the java web project. Right-click on your project select "Build Path" and "Configure Build path". In the "Libraries" tab double click on "JRE System Libraries" and select workspace Default workspace. If you do not have one installed, please install it and follow the above process.
Go to buildPath and in libraries double click on JRE System Libraries and select workspace Default workspace.
if your project is a maven project try mvn clean install command. It worked for me.
I was facing the same issue then I change changed my installed JRE and point to jdk and it worked for me.
Eclipse -> Windows -> Preferences -> Java -> Installed JRE -> Add new (gave the path of installed java jdk)
I had this problem in IntelliJ. I was using JDK version 1.8.0_333, but my Maven runner version was 11.0.1. When I changed that to 1.8.0_333, the errors went away.
The Maven Runner version can be set under Preferences->Build, Execution, Deployment->Build Tools->Maven->Runner.
I'm still mystified by the error, because that Maven runner works fine with all my other projects.

Categories

Resources