Windows 7 64-bit, with 64-bit JDK. Cordova plugman 1.4.2-dev. Using cygwin bash as a shell, but I don't see why that would affect anything.
$ echo $JAVA_HOME
"c:\Program Files\Java\jdk1.8.0_25"
$ echo $ANDROID_HOME
C:\Users\admin\AppData\Local\Android\Sdk
$ ls "c:\Program Files\Java\jdk1.8.0_25"
bin include lib release
COPYRIGHT javafx-src.zip LICENSE THIRDPARTYLICENSEREADME.txt
db jre README.html THIRDPARTYLICENSEREADME-JAVAFX.txt
$ ./main.js install --platform android --project ../myproject/ --plugin phonegap-facebook-plugin-gtg --variable APP_ID="1155264567919069" --variable APP_NAME="Voice Test"
Fetching plugin "phonegap-facebook-plugin-gtg" via npm
Installing "phonegap-facebook-plugin" for android
Failed to install 'phonegap-facebook-plugin':CordovaError: Failed to run "javac -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: "c:\Program Files\Java\jdk1.8.0_25"
I've also tried using JAVA_HOME without the quotes. What's going on?
#cubrr gave the correct answer in the comments. The error message being produced by Cordova is extremely misleading: the problem isn't that JAVA_HOME was incorrect, but that javac wasn't on my path. This was made all the more confusing by the fact that java was on my path, so when I checked it gave correct results. This is because the Oracle installer adds a directory to your path (c:\ProgramData\Oracle\Java\javapath) that contains links to java.exe and related programs but not the relevant JDK programs.
1) set > system variables > path to
`;C:\Program Files\Java\jdk1.8.0_xxx\bin;`
2) create new JAVA_HOME path with the value
C:\Program Files\Java\jdk1.8.0_xxx
now check javac version by issuing command at CMD
javac -version
*** don't touch the oracle - "C:\ProgramData\Oracle\Java\javapath;" path
If you are running windows 10, you need to restart your computer after changing the path and other variables. Possibly also on earlier windows versions.
I'm trying to compile a tool which uses apache ant on linux
https://github.com/lindenb/jvarkit
When I tried to compile the tool , I get n error.
$ make vcffilterjs
this is what I get when I'm running the command
echo "Compiling htsjdk with ${JAVA_HOME} = /usr/lib/jvm/java/jre/"
Compiling htsjdk with /usr/lib/jvm/java/jre/ = /usr/lib/jvm/java/jre/
echo "Compiling htsjdk library for java. Requires apache ANT. If it fails here, it's a not a problem with jvarkit."
Compiling htsjdk library for java. Requires apache ANT. If it fails here, it's a not a problem with jvarkit.
echo "And ${JAVA_HOME}/bin/javac should be >=1.7"
And /usr/lib/jvm/java/jre//bin/javac should be >=1.7
(cd /home/jannahS/jvarkit/htsjdk-1.139 && ant )
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
make: *** [/home/jannahS/jvarkit/htsjdk-1.139/dist/htsjdk-1.139.jar] Error 1
I have installed apache ant and tried to set ANT_HOME following google instruction
export ANT_HOME=apache-ant-1.9.6
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PAT
I also have set JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/jre-1.7.0
export PATH=$JAVA_HOME/jre/bin:$PATH
When I run
ant --execdebug
exec "/usr/lib/jvm/java/jre//bin/java" -Xmx256M -classpath "apache-ant- 1.9.6/lib/ant-launcher.jar" -Dant.home="apache-ant-1.9.6" -Dant.library.dir="apache-ant-1.9.6/lib" org.apache.tools.ant.launch.Launcher -cp ""
Buildfile: build.xml does not exist!
Build failed
I don't know what else to do to make things to work. I can't compile the tool that I want to use without apache ant
Use full path in ANT_HOME, eg:
export ANT_HOME=/usr/lib/apache-ant-1.9.6
It dependes where it is exactly located
Could not find or load main class org.apache.tools.ant.launch.Launcher
In mac this is due to some environment issue if you install the ant using brew command,
copy the lib folder from the ant and paste it into the bin folder
now run the command issue is resolved:-)
issue reason
ant is trying to get the bin/lib/ant-launcher.jar file from the invalid path
In Mac, after running brew install ant, I had to run brew link ant to fully link ant to system environment.
Running brew link --verbose --overwrite ant I get:
Linking /usr/local/Cellar/ant/1.10.5...
ln -s ../Cellar/ant/1.10.5/bin/ant ant
ln -s ../Cellar/ant/1.10.5/bin/antRun antRun
ln -s ../Cellar/ant/1.10.5/bin/antRun.pl antRun.pl
ln -s ../Cellar/ant/1.10.5/bin/complete-ant-cmd.pl complete-ant-cmd.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.pl runant.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.py runant.py
6 symlinks created
And when running "ant" with no params from command-line:
Buildfile: build.xml does not exist!
Build failed
Which is what I expect if testing outside the context of an existing ant project.
Run "which ant" >> to know if the ant_home set. If not please run below with your corresponding paths to set ant_home
export ANT_HOME =/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant
export PATH=/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant:${PATH}
Try ant build. It should work without any error.
"I agreed with full path issue for the above issue, getting the same exception while folder has access problem"
I have faced the same exception in Macbook. Checked all the configurations JAVA_HOME, ANT_HOME and org.apache.tools.ant.launch.Launcher file in Ant related jars. Finally, found the issue, due to an access problem of the apache-ant folder. I have no admin access, so I moved my setup to the desktop.
$ make vcffilterjs : Compiles OK, with any of these "Linux OS´s" :
Debian 8 Jessie, CentOS 7, Fedora 23, Ubuntu 15.10, PCLinuxOS 2015.
No "ANT_HOME" or "JAVA_HOME" settings required, by using the default installed 'ant' and openjdk.
? Which "Linux OS" are you using ?
antjvarkit
I'm trying to compile a jar on my mac using 1.8 as a target release, but javac fails with the message "invalid target release".
When I run javac -version it gives me "javac 1.6.0_29".
I have the 1.8 jdk installed under "/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk", but even when I run /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/javac -version it gives me "javac 1.6.0_29".
Sym linking the CurrentJDK folder in "/System/Library/Frameworks/JavaVM.framework/Versions/" to the jdk folder in Library didn't change anything. Neither did sym linking the javac inside /usr/bin to the javac in my jdk folder.
Any ideas how to get javac to use my 1.8 version ?
Thank you very much!
UPDATE
My path variables output the following:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/opt/X11/bin:/usr/local/git/bin:/Developer/Tools/Panda3D
echo $JAVA_HOME (since I set it already in order to get javac to work)
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/
Preprending /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/ to the $PATH variable didn't change the output for javac -version either.
UPDATE 2
Other question: What does javac do? Is it executing its code directly or depending on other binaries in the system? If so the link for them could be broken. Otherwise I wonder why executing the binary inside my 1.8 jdk folder gives me the version 1.6.
The proper Debian/Ubuntu way to configure which javac is pointed to by /usr/bin/javac is to use the update-alternatives command. You can do it interactively, and select from a list of available options:
sudo update-alternatives --config javac
and for java:
sudo update-alternatives --config java
In addition to what #Zakaria said, this command will show you all Java packages installed on the system, e.g.:
$ update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1069 /usr/lib/jvm/java-1.8.0-openjdk-amd64
This one an overview of the Java tools and which version will be used, e.g.:
$ update-alternatives --get-selections | grep java
...
java manual /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
javac auto /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
javadoc auto /usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc
...
As shown above here java would run from version 8, and javac from version 7.
If you want to update selections for all of the Java tools in one go try the following replacing the package name with one of your choice:
$ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
Verify that this has actually worked. If it didn't or partially did you have to resort to a semi-manual way, for example:
$ for i in $(update-alternatives --get-selections | grep java | awk '{system("basename "$3)}'); do sudo update-alternatives --config $i; done
where does the /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK link refer to?
Make sure it refers to the proper JDK
/Library/Java/JavaVirtualMachines/jdk{major}.{minor}.{macro[_update]}.jdk
Please check that both JAVA_HOME and PATH environment variables point to the 1.8 folder and have no link to the 1.6 java folder, especially the PATH.
Check:
echo %PATH%
Set:
export PATH="java8 folder":$PATH
or check this page: Set environment variables on Mac OS X Lion
Do the following steps
In the Windows Search bar, type "environment".
In your environment variables (account), create a variable called JAVA_HOME. Set it to C:\Program Files\Java\jdk1.8.0_65 (or wherever your JDK is).
In your system environment variables, edit PATH. Put this at the beginning of the PATH value: %JAVA_HOME%\bin;
Press OK.
Exit any command windows you are in.
Launch a command window. Type javac -version.
you should get this response: javac 1.8.0_65
When trying to run gradle, I get the following error:
# gradle
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
However, when I check the JAVA_HOME variable I get:
# echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
My JAVA_HOME is defined in .bashrc and I have double checked that it is set as the source.
Running java -version also confirms that JAVA_HOME is set correctly and is on the PATH.
# java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
I have also checked that /usr/bin/java symlinks to /etc/alternatives/java which in turn correctly symlinks to /usr/lib/jvm/java-7-oracle/jre/bin/java
Additionally I've checked that there are no duplicate JAVA_HOME definitions in .bash_profile or /etc/profile.
So my question is how/why does Gradle find /usr/lib/jvm/default-java, and more importantly how do I point it to the correct directory?
Other programs which require the JDK work fine, so I think its a Gradle issue. I've also tried reinstalling Gradle which made no difference.
I'm running 64bit Xubuntu (Ubuntu 13.10 base)
Turns out that the particular Gradle binary I downloaded from the Ubuntu 13.10 repository itself tries to export JAVA_HOME. Thanks to Lucas for suggesting this.
/usr/bin/gradle line 70:
export JAVA_HOME=/usr/lib/jvm/default-java
Commenting this line out solves the problem, and Gradle finds the correct path to the Java binary.
If you just download the binary from their website it does not have this problem,
It's an issue with the Ubuntu repo version. There also seem to be some other issues with 13.10 version.
add a symbolic link
sudo ln -s /usr/lib/jvm/java-7-oracle /usr/lib/jvm/default-java
Solution is to make JAVA_HOME == dir above bin where javac lives as in
type javac
javac is /usr/bin/javac # now check if its just a symlink
ls -la /usr/bin/javac
/usr/bin/javac -> /etc/alternatives/javac # its a symlink so check again
ls -la /etc/alternatives/javac # now check if its just a symlink
/etc/alternatives/javac -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
OK so finally found the bin above actual javac so do this
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
above can be simplified and generalized to
which javac >/dev/null 2>&1 || die "ERROR: no 'javac' command could be found in your PATH"
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac) )))
For me this error was due to the reason Gradle as installed as sudo and I was trying as default user to run Gradle.
Try:
sudo gradle -version
or
sudo gradle -v
In my Ubuntu, I have a headache for 2 days on this issue.
Step 1. Type on the terminal whereis java
then it will display something like this
java: /usr/bin/java /etc/java /usr/share/java /usr/lib/jvm/java-8-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz
Step 2. Take note of the path:
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
exclude the bin/java
your JAVA_HOME = /usr/lib/jvm/java-8-openjdk-amd64
Did you export your JAVA_HOME? Without export, the setting will not be propagated to the commands started inside of that shell. Also, java -version does not use JAVA_HOME, rather it uses the first java found in your path. Make sure your .bashrc looks something like this:
JAVA_HOME=/path/to/java/home
export JAVA_HOME
Try installing latest version of gradle,
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
If we install from ubuntu repo, it will install the old version , (for me it was gradle 1.4). In older version, it sets java home from gradle as export JAVA_HOME=/usr/lib/jvm/default-java. Latest version don't have this issue.
I faced this issue when I run the following command on Ubuntu:
ionic build android
To solve this issue, I did the following steps:
ln -sf /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java /usr/lib/jvm/default-java
Add JAVA_HOME to /etc/environment:
vi /etc/environment
Add:
JAVA_HOME="/usr/lib/jvm/default-java"
After saving, read it:
source /etc/environment
Finally, you can run build command.
I had the same problem, but I didnt find export command in line 70 in gradle file for the latest version 2.13, but I understand a silly mistake there, that is following,
If you don't find line 70 with export command in gradle file in your gradle folder/bin/ , then check your ~/.bashrc, if you find export JAVA_HOME==/usr/lib/jvm/java-7-openjdk-amd64/bin/java, then remove /bin/java from this line, like JAVA_HOME==/usr/lib/jvm/java-7-openjdk-amd64, and it in path>>> instead of this export PATH=$PATH:$HOME/bin:JAVA_HOME/, it will be export PATH=$PATH:$HOME/bin:JAVA_HOME/bin/java. Then run source ~/.bashrc.
The reason is, if you check your gradle file, you will find in line 70 (if there's no export command) or in line 75,
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
That means /bin/java is already there, so it needs to be substracted from JAVA_HOME path.
That happened in my case.
I have tested this on Manjaro Linux. Should work on other Disto too.
You need to include whole java-jdk dir instead of just java/bin for java env var.
For example, instead of:
export JAVA_HOME=/opt/jdk-14.0.2/bin #change path according to your jdk location
PATH=$PATH:$JAVA_HOME
use this:
export JAVA_HOME=/opt/jdk-14.0.2/ #change path according to your jdk location
PATH=$PATH:$JAVA_HOME
then run the gradle command it will work.
You can also go to the bin folder inside your gradle installation folder and correct the JAVA_HOME parameter in gradle.bat file.
In my case, my JAVA_HOME was set to c:\Program files\java\bin
The JAVA_HOME in gradle.bat was set to %JAVA_HOME%\bin\java.exe.
I corrected the JAVA_HOME in gradle.bat and it worked.
Thank you!!!
Before running the command try entering:
export JAVA_HOME="path_to_java_home"
Where path_to_java_home is the folder where your bin/java is.
If java is properly installed you can find it's location, by using the command:
readlink -f $(which java)
Don't forget to remove bin/java from the end of the path while putting it into JAVA_HOME
For me an explicit set on the arguments section of the external tools configuration in Eclipse was the problem.
sudo ln -s /usr/lib/jvm/java-7-oracle/jre /usr/lib/jvm/default-java
Create a symbolic link to the default-java directory.
You can find your java directory by
readlink -f $(which java)
# outputs: /usr/lib/jvm/java-7-oracle/jre/bin/java
# Remove the last `/bin/java` and use it in above symbolic link command.
I had a problem with this too. It said wrong directory when it was correct. So I just created a local variable with the name of JAVA_HOME omitting the final /bin/java. It worked fine for me.
If your GRADLE_HOME and JAVA_HOME environment are set properly then check your JDK directory and make sure you have java.exe file under below path.
C:\Program Files (x86)\Java\jdk1.8.0_181\bin
As error mentioned in gradle.bat file
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
It is not able to locate your java installation. So find and set
java.exe
under %JAVA_HOME%/bin if everything is correct.
This works for me (my account got disabled by client and their admin has removed java.exe from my directory.)
[Windows] As already said, it looks like .bat -file tries to find java.exe from %JAVA_HOME%/bin/java.exe so it doesn't find it since bin is repeated twice in path.
Remov that extra /bin from gradle.bat.
In my dockercontainer (being minimal the problem of not finding java) was, that "which" was not installed. Comipling a project using gradlew used which in ./gradlew to find java
Installing which solved the problem.
Adding below lines in build.gradle solved my issue .
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
#ISSUE:GradleException: javaConfig.targetVersion is Java 8, but the environment variable JAVA8_HOME does not exist
I think this is how you fix it in IntelliJ. I've run into it a couple times as I choose "Launch in New Window" for a new project but I haven't written down the steps yet.
1.File -> Project Structure. Project Settings / Project. Make sure Project SDK and Project language level are correct.
2.Preferences. Build, Execution, Deployment / Build Tools / Gradle. Make sure Gradle JVM is correct.
You may have to restart IntelliJ after this.
NOW it SOLVED THE ISSUE
Task :prepareKotlinBuildScriptModel UP-TO-DATE
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 22s
I am trying to clean my Maven and I am getting this warning when I run mvn eclipse:eclipse -Dwtpversion=2.0
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Does any one have a clue on how to fix it?
I am on MacOS. Here is what I have configured for my eclipse:
There is a patch here, but it has not been applied to any release so far. :-( As a workaround you can create a symlink as described here.
The answer above works, but seems to be more than what's needed.
Minimally on OSX Lion, you may get by with:
cd /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
sudo mkdir -p jre/lib
cd jre/lib
sudo ln -s ../../../Classes/classes.jar rt.jar