Should versions of java & javac be same in the system? - java

Should java & javac version be same in the system?
as I am having java -version
java version "1.8.0_251" Java(TM) SE Runtime Environment (build
1.8.0_251-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
and javac -version
javac 1.8.0_181
Is there any issue if it's not the same version?

Should java & javac version be same in the system?
Not really, you can have as many java version as you want on one system, as long as you know which version you use when compiling or running application. If you have multiple java version in your system, be aware which version you put on your PATH environment variable to avoid a miss.
Your problem should be caused by multiple entry in your PATH environment variable that refering to java installation directory that has different version (note, java can be found in JDK and JRE installation, while javac can only be found in JDK installation).
Is there any issue if it's not the same version?
There should be no issue, as long as you don't use features that can only be found on the java version you use when compiling the program. In your case, the different is in build version, it's okay.

Related

JDK not found on Debian 8.5

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

How to install alt JDK on Mac without overriding current one

Mac here (Yosemite 10.10.5). I am using JDK 8 for all my projects, and recently just inherited an “older” Java 7-based project. I would simply like to download a Java 7 JDK from Oracle's archived JDKs, however it only seems to be available as a DMG (auto-installer).
I’m afraid that if I download this DMG it will auto-install it and make Java 7 my default installation. Whereas, I only want the unzipped JDK on my local file system, so that I can run my Java 7 app off of it (by specifying the full path to the JDK when I run the app locally).
Any ideas as to what my options are?
Most of the information about this can be found in Oracles notes on installation
I believe what you are looking for specifically is under
Determining the Default Version of the JDK:
There can be multiple JDKs installed on a system, as many as you wish.
When launching a Java application through the command line, the system uses the default JDK. It is possible for the version of the JRE to be different than the version of the JDK.
You can determine which version of the JDK is the default by typing java -version in a Terminal window. If the installed version is 8u6, you will see a string that includes the text 1.8.0_06. For example:
% java -version
java version "1.8.0_06-ea"
Java(TM) SE Runtime Environment (build 1.8.0_06-ea-b13)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b04, mixed mode)
To run a different version of Java, either specify the full path, or use the java_home tool:
% /usr/libexec/java_home -v 1.8.0_06 --exec javac -version

Trying to run an Android project in IntelliJ: Error:Abnormal build process termination: Error: This Java instance does not support a 32-bit JVM.

Error:Abnormal build process termination:
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
How to fix it?
Java version:
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
JAVA_HOME:
$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
I also have JDK 1.8 installed...
In the general settings for your project, you need to specify the right SDK. You need to download the required java version, and then find the path to its home and then point to it in General Settings > Project > Project SDK. Likely, you need to upgrade to a newer version.

java version value is different with java and javac

I am getiing java versions different with java command and javac command
java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode, sharing)
javac -version
javac -version
javac 1.6.0_18
where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.6.0_18\bin\java.exe
path is set to 1.6 but it is picking 1.8
suggest me how to get this resolved.
This is cause by the extremely annoying habit of the Java installer to copy java.exe andjavaw.exe to C:\Windows\System32\java.exe when you choose to install the "public jre" (but because that's the JRE, of course no javac.exe is copied).
And because System32 comes early in the PATH java.exe from there will be used (and before the regular JDK installation will no be searched for java.exe). But as there is no javac.exe in the JRE, that in turn is used from your JDK.
The public JRE is only needed for the browser Java plugin. In 2014 I consider the Java plugin to be dead and (I think) Oracle should change the JDK installer to not install that automatically.
Actually I consider this behaviour a bug to be honest. No installer should copy files to system32

java - how can I have both versions 1.6 and 1.7 at the same time (osx)?

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

Categories

Resources