I want to make a python-android-app using this software. I have installed java JDK, when i run java -version i get:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
However running the line python android.py installsdk from witin rapt directory (as described in the tutorial) tells me that i have no JDK:
I'm compiling a short test program, to see if you have a working JDK
on your system.
I was unable to use javac to compile a test file. If you haven't
installed the Java Development Kit yet, please download it from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
The JDK is different from the JRE, so it's possible you have Java
without having the JDK. Without a working JDK, I can't continue.
You need to set your jdk to be accesible, and within path / java home :)
Here help from google:
To set JAVA_HOME environment variable, do the following: Launch
Terminal by pressing Ctrl + Alt + T on your keyboard. Depending on
where you installed your Java, you will need to provide the full path.
For this example, I installed Oracle JDK 7 in the
/usr/lib/jvm/java-7-oracle directory.Aug 13, 2012
I have legacy code that uses jruby that needs java 1.6
My current setup is:
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
08:42:11 mdurrant C02MH2DQFD58 /Users/mdurrant
$ ruby --version
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on
Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
Now I want to use eclipse and the latest version requires the jdk version 1.7
How can I add that and then have them co-exist?
I'm worried that this will effectively upgrade my existing 1.6 to 1.7 (the newer gives me lots of memory issues in my apps - yeah that's as backwards as it sounds, the newer version being worse at memory management - probably due to how our apps are built).
Install as a default JRE from Java Build Path -> JRE System
Library -> Installed JRES -> Add ...
or
You can specify JDK version for usage with Eclipse in eclipse.ini. This will resolve problem with starting Eclipse.
-vm // Add this configuration before -vmargs.
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java
or You can install jenv
jenv is for a equivalent of rbenv, but for Java environnement. It allow to easily switch between several JDKs installations (already presents), and configure which one to use per project.
Install or specify as a default JRE in eclipse from Java Build Path -> JRE System Library -> Installed JRES -> Add .
otherwise specify the default Jdk file in eclipse.ini configuration file
I am new to Ubuntu and trying to install a particular version of java.
I downloaded the jdk1.7.0_51 binaries in my Ubuntu machine and exported the variable JAVA_HOME='home/programs/jdk1.7.0_51 and the PATH=$PATH:$JAVA_HOME/bin. However when I type java -version in the command line I get:
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
The displayed java version (1.6.0_27) is different than the version declared in the PATH. There was an older version which I removed through the software center but the issue remains. Any help would be greatly appreciated.
That's because you already have openjdk installed (by default probably) on your system and the binaries provided by openjdk are already registered in $PATH. And that's where your problem is. Downloading the oracle jdk binaries and installing them in a custom location and exporting that location in JAVA_HOME, is not enough. You also need to add the path to the jdk binaries (javac, java, jar, etc) to the PATH environment variable.
A better way to do this is to install the oracle jdk via pre-packaged versions provided by ubuntu community: link. This would configure the path for you and set the necessary environment variables. And use alternatives to configure which would be the default jdk to use:
update-alternatives --config java
Or simply remove openjdk if you don't need it.
I am trying to setup Android build environment for my Mac 10.8.3
I dont understand, Apple provide instructions on how to revert mac back to Java 1.6 here :
http://support.apple.com/kb/HT5559?viewlocale=en_US&locale=en_US
They are clear instructions that I followed.
Yet when I still get the following :
unknown-98:fe:94:3f:92:ce:~ newuser$ java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Please please help me solve this problem.
The Mac comes with, and occasionally updates, JDKs 1.4 through 1.6. You can see the versions you have installed in this directory:
/System/Library/Frameworks/JavaVM.framework/Versions
This is how you change the JDK
1. Command Line Java
My Java is coming from /usr/bin/java, which points off to one of the versions in the 'Versions' dir described above. To change the version of the JDK you're getting here, use the Java Preferences application under Applications -> Utilities -> Java:
You can drag the JDK you'd like to the top and it should be reflected immediately from the command line:
hostname% java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_16-133, mixed mode)
hostname% java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
2. Scripts and Applications That Use Java
Generally, other built-in applications or one that you install will use the JAVA_HOME environment variable to pick a JDK. By default, you won't have this set, and Mac-specific versions of startup scripts will usually create one by using the CurrentJDK link in the Java 'Versions' directory. The steps to add environment variables are documented in this article, but I can save you a little time. Create a directory .MacOSX in your home directory and add a file called environment.plist. Here are the entire contents of my ~/.MacOSX/environment.plist file:
<!-- When changing this, also run Java Preferences and change there. -->
<key>JAVA_HOME</key>
<string>/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home</string>
With this value set, all processes started as you will have JAVA_HOME available to them. Since this file is read when you log in, you'll have to log out/in once after you create or edit this file.
Special case: NetBeans
The IDE I use is NetBeans, but the following idea probably applies to other large applications as well. When NetBeans is installed, it will pick a JDK to use and hard code it in a properties file. If you want it to rely on the JAVA_HOME that you're now setting in environment.plist, you just need to edit one file. Edit this file:
/Applications/NetBeans/NetBeans\ 6.5.app/Contents/Resources/NetBeans/etc/netbeans.conf
..and you can set the JDK by changing this line:
netbeans_jdkhome=$JAVA_HOME
Note that, as the netbeans.conf file points out, you can always force a different JDK to be used by specifying it on the command line when starting the IDE. For your copying and pasting pleasure, here is the command to use to start it from terminal (I'm giving the 'help' option in this case). If you're using a different version, autocomplete ought to help with the version part of the path:
/Applications/NetBeans/NetBeans\ 6.5.app/Contents/MacOS/netbeans
--help
Recap
To recap, you can switch JDKs for your whole system by using the Java Preferences application along with changing the value in your environment.plist file. To switch on the fly, use the Preferences app and set a new value for JAVA_HOME in whatever terminal you're using, though some apps like NetBeans will still pick up the system value and you should specify the desired JDK on the command line.
Resources where I found this solution: https://blogs.oracle.com/bobby/entry/switching_jdks_on_mac
I'm in the situation where I've installed the JDK, but I can't run applets in browsers (I may not have installed the JRE).
However, when I install the JRE, it clobbers my JDK as the default runtime. This breaks pretty much everything (Eclipse, Ant) - as they require a server JVM.
There's no JAVA_HOME environment variable these days - it just seems to use some registry magic (setting the system path is of no use either). Previously, I've just uninstalled the JRE after I've used it to restore the JDK. This time I want to fix it properly.
This also manifests itself with the jre autoupdater - once upon a time, I had a working setup with the JDK and JRE, but it updated and bust everything.
This is a bit of a pain on Windows. Here's what I do.
Install latest Sun JDK, e.g. 6u11, in path like c:\install\jdk\sun\6u11, then let the installer install public JRE in the default place (c:\program files\blah). This will setup your default JRE for the majority of things.
Install older JDKs as necessary, like 5u18 in c:\install\jdk\sun\5u18, but don't install the public JREs.
When in development, I have a little batch file that I use to setup a command prompt for each JDK version. Essentially just set JAVA_HOME=c:\jdk\sun\JDK_DESIRED and then set PATH=%JAVA_HOME%\bin;%PATH%. This will put the desired JDK first in the path and any secondary tools like Ant or Maven can use the JAVA_HOME variable.
The path is important because most public JRE installs put a linked executable at c:\WINDOWS\System32\java.exe, which usually overrides most other settings.
I have patched the behaviour of my eclipse startup shortcut in the properties dialogue
from
"E:\Program Files\eclipse\eclipse.exe"
to
"E:\Program Files\eclipse\eclipse.exe" -vm "E:\Program Files\Java\jdk1.6.0_30\bin"
as described in the Eclipse documentation
It is a patch only, as it depends on the shortcut to fix things...
The alternative is to set the parameter permanently in the eclipse initialisation file.
I just had that problem (Java 1.8 vs. Java 9 on Windows 7) and my findings are:
short version
default seems to be (because of Path entry)
c:\ProgramData\Oracle\Java\javapath\java -version
select the version you want (test, use tab completing in cmd, not sure what those numbers represent), I had 2 options, see longer version for details
c:\ProgramData\Oracle\Java\javapath_target_[tab]
remove junction/link and link to your version (the one ending with 181743567 in my case for Java 8)
rmdir javapath
mklink /D javapath javapath_target_181743567
longer version:
Reinstall Java 1.8 after Java 9 didn't work. The sequence of installations was jdk1.8.0_74, jdk-9.0.4 and attempt to make Java 8 default with jdk1.8.0_162...
After jdk1.8.0_162 installation I still have
java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
What I see in path is
Path=...;C:\ProgramData\Oracle\Java\javapath;...
So I checked what is that and I found it is a junction (link)
c:\ProgramData\Oracle\Java>dir
Volume in drive C is OSDisk
Volume Serial Number is DA2F-C2CC
Directory of c:\ProgramData\Oracle\Java
2018-02-07 17:06 <DIR> .
2018-02-07 17:06 <DIR> ..
2018-02-08 17:08 <DIR> .oracle_jre_usage
2017-08-22 11:04 <DIR> installcache
2018-02-08 17:08 <DIR> installcache_x64
2018-02-07 17:06 <JUNCTION> javapath [C:\ProgramData\Oracle\Java\javapath_target_185258831]
2018-02-07 17:06 <DIR> javapath_target_181743567
2018-02-07 17:06 <DIR> javapath_target_185258831
Those hashes doesn't ring a bell, but when I checked
c:\ProgramData\Oracle\Java\javapath_target_181743567>.\java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
c:\ProgramData\Oracle\Java\javapath_target_185258831>.\java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
so to make Java 8 default again I had to delete the link as described here
rmdir javapath
and recreate with Java I wanted
mklink /D javapath javapath_target_181743567
tested:
c:\ProgramData\Oracle\Java>java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
** update (Java 10) **
With Java 10 it is similar, only javapath is in c:\Program Files (x86)\Common Files\Oracle\Java\ which is strange as I installed 64-bit IMHO
.\java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
After many attempts, I found the junction approach more convenient. This is very similar on how this problem is solved in linux.
Basically it consists of having a link between c:\tools\java\default and the actual version of java you want to use as default in your system.
How to set it:
Download junction and make sure to put it in your PATH
environment variable
Set your environment this way:
- PATH pointing to ONLY to this jre c:\tools\java\default\bin
- JAVA_HOME pointing to `c:\tools\java\default
Store all your jre-s in one folder like (if you do that in your Program FIles folder you may encounter some
C:\tools\Java\JRE_1.6
C:\tools\Java\JRE_1.7
C:\tools\Java\JRE_1.8
Open a command prompt and cd to C:\tools\Java\
Execute junction default JRE_1.6
This will create a junction (which is more or less like a symbolic link in linux) between C:\tools\java\default and C:\tools\java\JRE_1.6
In this way you will always have your default java in c:\tools\java\default.
If you then need to change your default java to the 1.8 version you just need to execute
junction -d default
junction default JRE_1.8
Then you can have batch files to do that without command prompt like
set_jdk8.bat
set_jdk7.bat
As suggested from #СӏаџԁеМаятіи
EDIT: From windows vista, you can use mklink /J default JRE_1.8
I simply install all the versions of JDK I need and the latest installed becomes default, so I just reinstall the one I want to be default if necessary.
I have several JDK (1.4, 1.5, 1.6) installed in C:\Java with their JREs. Then I let Sun update the public JRE in C:\Program Files\Java.
Lately there is an improvement, installing in jre6. Previously, there was a different folder per new version (1.5.0_4, 1.5.0_5, etc.), which was taking lot of space
an alterable way to run an .jar app is create an .bat cmd for it.
for example, you have jre10 and jre8 installed on your pc,and jre10 is your default jre.
but your jar is specified to work with jre8,following cmd will work:
"C:\Program Files\Java\jre1.8.0_181\bin\java.exe" -jar JabRef-4.3.1.jar
Need to remove C:\Program Files (x86)\Common Files\Oracle\Java\javapath from environment and replace by JAVA_HOME which is works fine for me
Stacked by this issue and have resolved it in 2020, in Windows 10. I'm using Java 8 RE and 14.1 JDK and it worked well until Eclipse upgrade to version 2020-09. After that I can't run Eclipse because it needed to use Java 11 or newer and it found only 8 version. It was because of order of environment variables of "Path":
I suppose C:\Program Files (x86)\Common Files\Oracle\Java\javapath is path to link to installed JRE exe files (in my case Java 8) and the issue was resolved by move down this link after %JAVA_HOME%, what leads to Java 14.1/bin folder.
It seems that order of environment variables affects order of searched folders while executable file is requested.
Thanks for your comment or better explanation.