Ant - Eclipse [Reference to undefined variable INSTALLED_PATH] - java

I cannot run ant files in eclipse, when i try to run them the following dialog appears.
SOLVED: I am not sure what was the problem, but I think the java/ant path in windows path variable was the problem.
However I have removed any extra value from windows path variable; restart the computer and now every thing works fine.

Referred from : Eclipse 3.7, Ant, Java 1.7
In Eclipse, click the ant file -- Run As -- External Tools Configuration and click on the JRE tab.
Select "Run in the same JRE as the workspace"

I think The problem is because of:
You are using INSTALLED_PATH variable in your ant script which is not undefined.

specify value for INSTALLED_PATH in the below screen
Right click on ant file, then choose Run AS-> Ant build(2 Option), then select environment tab in the pop up, then add a new variable "INSTALLED_PATH"

Related

In Intellij IDEA 14.1.4: Cannot run program "C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java"

I am trying to run a java-based Play 2.0 app in IDEA, but upon compilation, I get this error:
Information:Internal caches are corrupted or have outdated format,
forcing project rebuild: Module 'web-server' production:
java.io.IOException: Cannot run program "C:/Program Files
(x86)/Java/jdk1.8.0_45/bin/java" (in directory
"C:\Users\\Documents\GitHub\\web-server"):
CreateProcess error=267, The directory name is invalid
This occurs during a ProcessBuilder.start() action.
I have made sure all the path variables are properly set, even changing them up to ensure that they work properly. The thing that gets me here is that it seems like ProcessBuilder is trying to use forward slash paths, but I'm running in Windows.
I've tried reloading my project from scratch, invalidating the cache and restarting, updating my java installation (both 32- and 64-bit), and uninstalling and reinstallating IDEA, but it just won't seem to work. This same project runs fine on another computer, so I'm thinking it might be a local issue. Any help would be greatly appreciated!
I had this problem recently, i solved in 2 steps.
Part 1
If your path JAVA_HOME is OK:
File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner
Set to "use JAVA_HOME (...Path...)"
If you set with a fixed string, the problem may reappear when in future you will re-update. Anyway, you can do that.
Part 2
File → Other Settings → Default Project Structure
Check all the tabs and ensure that all the path point to the newly installed JDK (If you change in one, then you should have all changed, e.g. i changed in Annotations)
If you cannot select the path (error: not valid path), try not to use the one in C:\Program Files (x86)\Java...\ -- select the one in C:\Program Files\Java...\ (or viceversa)
I had the same issue, here is how I solved it:
Clearly there is something wrong with the directory path. Mine was "D:\IntelliJ Workspace\" but in error message it was "D:\IntelliJ+Workspace\". When I remove the space in directory name the error was fixed.
In your situation "C:\Users\\Documents\GitHub\\web-server" has extra back slashes so when you fix this, I think your error will be fixed.
Had the same issue as the folder containing the project has spaces in its name. Worked perfectly after removing the spaces and renaming it.
I had same issue with idea 14.1.4.
Changing Maven Runner option to Use JAVA_HOME helped.
Settings > Maven > Runner
Set JRE to Use JAVA_HOME.
i changed from jdk1.7 to jdk1.8.0_212 and it worked
however during compile time i am usind jdk 1.7 and in run time its jdk1.8.0_212
I had a similar issue-
Cannot run program "E:\Java\jdk-17.0.2\bin\java.exe" (in directory with idea 14.1.4)
Solution:
1.Delete your jdk
1.Reinstall your jdk.
2.Then again build your project and save,run it.

I tried to run Java in Eclipse and it asks me to select ant build and either one I choose it says unable to find ant file to run...

So I just installed JRE, JDK and Eclipse and I was trying to run this famous HelloWorld code, but it shows this message as in attached images. What's the ant build?
Thanks!
dont run it as ant, right click on your file in eclipse select run as then choose java application
It looks like you don't have your file in your buildpath (what eclipse uses to figure out what files it should compile). Right click on the folder and select Buildpath -> Use as Source folder. Now when you hit run it should hopefully work.
Go to Run
Run Configurations
Select Java Application(From Left Pane)
Fill Up Your Project Name and your Main Class
Apply and Run
example image
Best way is to
Delete all eclipse files in your pc and again download eclipse and install it. Definitely works
Click Run As > Java.
If Java is not available there, click Run Configurations > JRE.
Choose "Execution environment" , click Environments and choose the Java version you want to use. Click Apply, Run.
That should do it.
Try to create a Java class file with suitable name and method.This error usually occurs when compiler doesn't understand which file to execute.
Simply click the javadoc next to your console and run it

Running Gradle project via Eclipse errors "system Cannot find System Java Compiler"

When I run Gradle project via Eclipse I get below error.
system Cannot find System Java Compiler.
Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
Could not execute build using Gradle installation 'C:\gradle-1.2-all\gradle-1.2'.
But I have installed JDK 1.7 and set the JAVA_HOME environment variable.
Go to File -> Other Settings -> Default Project Structure
Now Set your JDK location
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.
On my laptop it's "jdk1.6.0_45". Yours should be the JDK 1.7 home folder, something like "/usr/lib/jvm/java-7-openjdk-amd64/".
You can face this problem even when all your system variables are set and correct. Usually this happens when you work with foreign code from Github etc.
So what you have to do is to check gradle version in your project level build.gradle file, and if it doesn't match to current installed version, update it.
buildscript {
//other setupps
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0' //update this to your current version
}
}
In Gradle Task View -> build -> right click->Open Gradle Configuration -> JAVA_HOME -> and put the current value of your enviroment, something like C:\Program Files\Java\jdk1.7.0_79
I hope this help you
I tried following, but in Eclipse (luna), Run as, "gradle build Gradle build", still failed.
change JAVA_HOME
Preference, Gradle -> Arguments -> Java Home, select "Workspace
JRE".
Solution: Go command line, run gradle build as answered by user3754672, then back to Eclipse, all working.
It's likely you haven't installed a JDK. Even though you have "jdk1.7", you may have only the runtime environment. You may need to install the "-devel" option for the package, for example, both these would be required:
java-1.7.0-openjdk
java-1.7.0-openjdk-devel
If you can't find the right package, tell us your distro and the exact name of the jdk1.7 package you have so we can help more.
Although you may have a full JDK installed somewhere, and pointed to by JAVA_HOME, I don't think the Eclipse Gradle plugin will use it by default. I ran into the same problem running the the "test" target for the Gradle "quickstart" app in Springsource Groovy/Grails Tool Suite 3.3.0(Gradle IDE 3.3.0.201307040643 plugin).
If you re-run the failed Gradle target from the "External Tools" menu (under the "arrow with a suitcase icon"), adding "--debug" in the "Program Args" under the Arguments tab, it will show you in the console what JVM/JDK it uses. I was able to get around the problem by deselecting "Use Gradle wrapper's default" in the Java Home section of the Arguments tab, and replacing it with an Execution Environment setting that pointed to my 1.7 JDK that I had installed. I'm sure there's a way to have it do this by default, so you don't have to configure each targets run configuration, but this method should fix the immediate problem.
I think the wrapped gradle uses the same java as eclipse. Since Eclipse seems to use jre by default you can get the issue mentioned in the question.
Try this: Go to your eclipse.ini and add -vm argument like this:
-vm
c:/java/jdk1.8/javaw.exe
Issue
Using the Eclipse -> gradle -> select task to execute and
error "...cannot find system java compiler."
Solution
Go to the path where your build.gradle path is... and using the cmd manually type
gradle build <- this will work.
Done.
Back to Eclipse and execute the gradle task. It will work again!
Change your gradle to min: classpath 'com.android.tools.build:gradle:2.0.0'and then Android Studio will ask you to update it. You will make and update of gradle and after that it will work.That is how I fixed it for me.
I deleted some old jdk's and encountered the same issue. None of the above outdated solutions worked. Gradle in its infinite wisdom stores the JDK location in C:\Users\User.gradle\gradle.properties. This property is not accessible via the IDE as far as I know.
My Eclipse version:
Eclipse Java EE IDE for Web Developers.
Version: Photon Release (4.8.0)
Right click 'gradle.build' and then choose 'run as' -> 'Run Configurations'. In the left, choose 'gradle.build' under 'Gradle Project'. In the right, you could see something like 'Gradle Tasks', 'Project Settings', 'Java Home' and so on. Choose 'Java Home', you will see there is an input box. Put your JDK path there. (something like: C:\Program Files\Java\jdk-10) And then run.

Java - Different behaviour between exported JAR and Eclipse IDE

today I got a strange problem while trying to call a batch file from Eclipse IDE.
The setting for a normal user is:
Call a .bat file
This sets some environment variables
And calls a Eclipse RCP application
The setting for my program is:
Call the same .bat file via Runtime.exec()
When calling it as normal user, all works well, the RCP gets started.
When calling it within Eclipse IDE via Runtime.exec() I get an error message complaining that Program Files\jre6\bin\server\jvm.dll could not be found (although it is there).
When exporting my program as an executable .jar file, it works well like I would click on the .bat myself.
What is the difference? (Operating system is Win7)
In Eclipse,
Right click on the project and click "Properties".
Select "Java Build Path".
Select "Libraries" tab.
Select "JRE System Library" and click "Edit".
Check if the System Library points to a valid JDK installation(not JRE). If it doesn't point to a valid JDK installation.
Select "Alternate JRE" and click on "Installed JREs"
Click on Add, point to valid JDK installation and click OK.
In "Alternate JRE" drop down, select the newly added valid JDK and click Finish.
Run the program and check.
Ok got it.
It seems to be a specific problem of Eclipse 3.7.
After installing 4.2 all works perfectly well.

Eclipse Java Version Incorrectly Set Somewhere

I do not believe this is a duplicate of any of the previous questions concerning Java in Eclipse.
yesterday my machine updated its java version, and after it did that I opened my Eclipse IDE and found I couldn't build most of my Java projects. The last time I used eclipse everything worked and I had not changed any settings.
I should be using java 1.7_80 (my work projects require this), but now when I build my projects eclipse says it is looking for java 1.8_71- but then eclipse says its using java 1.8_77; all the while my Java compiler settings still says I'm using java 1.7...
The Question: Are there any other places in Eclipse where it sets what version of Java is used?
Note: Java 1.7_80 is still in my PATH System Environment variable; those other newer versions are not and never were. I am using ANT. Below are some images to show my problems and settings.
Check Window->Preferences->Installed JREs, there eclipse uses the checked JRE to compile and run your product per default.
There is also a "Java Runtime Environment" option in your Run configuration.
You can also specify project specific Java Compiler options, rightclick Properties on your project.
Edit: for ant launches, see printscreen below:
Edit2: ok I think for Ant, compiler options are irelevant.
What you can try is storing your ant launch in your project and open it with a text editor and search for invalid java configurations:
open your ant launch
goto Common
change to Shared file
choose your project
Try right clicking on the project and select "Build Path" and "Configure build path". Then select the library and change the library to the desired one. Also to check which version of java is install you can use "java -version" in terminal/ command prompt.

Categories