0


When I execute java.exe -version
Both JDK and JRE say: SE Runtime Environment
Is there other way to distinguish JDK or JRE

C:\Program Files\Java\1.6.0_45\bin>java.exe -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
JavaSheriff
  • 7,074
  • 20
  • 89
  • 159

3 Answers3

1

Simple enough... Try and:

javac.exec -version

If you get a message telling the version, you have the JDK. If you have a message telling you that the command is not found, you have the JRE.

fge
  • 119,121
  • 33
  • 254
  • 329
1

If you take a look at the folder structure where jdk / jre is installed you would see that in the jdk/bin folder there are quite a collection of binaries such as java, javac, javap etc. The JRE would include java but not javac, javap etc. I am assuming this is linux and you downloaded the compressed archive and extracted that.

But this is not the only difference, the JDK is the development kit that includes the JRE as well. If you are interested in running java programs then JRE would suffice but if there is development including compilation then the JDK is required. Please also see: What is the difference between JDK and JRE?

The bin folder structure differences between JDK and JRE (for example):

For the JRE:

$ ll jre/bin/
total 452K
lrwxrwxrwx. 1 ec2-user ec2-user    8 Nov 18 18:27 ControlPanel -> jcontrol
drwxr-xr-x. 5 ec2-user ec2-user 4.0K Sep 17 20:42 ..
drwxr-xr-x. 2 ec2-user ec2-user 4.0K Sep 17 20:42 .
-rwxr-xr-x. 1 ec2-user ec2-user 7.6K Sep 17 20:42 java
-rwxr-xr-x. 1 ec2-user ec2-user 130K Sep 17 20:42 javaws
-rwxr-xr-x. 1 ec2-user ec2-user 6.2K Sep 17 20:42 jcontrol
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jjs
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 keytool
-rwxr-xr-x. 1 ec2-user ec2-user 8.0K Sep 17 20:42 orbd
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 pack200
-rwxr-xr-x. 1 ec2-user ec2-user 7.9K Sep 17 20:42 policytool
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 rmid
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 rmiregistry
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 servertool
-rwxr-xr-x. 1 ec2-user ec2-user 8.0K Sep 17 20:42 tnameserv
-rwxr-xr-x. 1 ec2-user ec2-user 224K Sep 17 20:42 unpack200

For the JDK:

$ ll jdk/bin/

total 780K
lrwxrwxrwx. 1 ec2-user ec2-user    8 Nov 18 18:27 ControlPanel -> jcontrol
drwxr-xr-x. 8 ec2-user ec2-user 4.0K Sep 17 20:44 ..
drwxr-xr-x. 2 ec2-user ec2-user 4.0K Sep 17 20:42 .
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 appletviewer
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 extcheck
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 idlj
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jar
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jarsigner
-rwxr-xr-x. 1 ec2-user ec2-user 7.6K Sep 17 20:42 java
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 javac
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 javadoc
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 javah
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 javap
-rwxr-xr-x. 1 ec2-user ec2-user 1.8K Sep 17 20:42 java-rmi.cgi
-rwxr-xr-x. 1 ec2-user ec2-user 130K Sep 17 20:42 javaws
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jcmd
-rwxr-xr-x. 1 ec2-user ec2-user 7.9K Sep 17 20:42 jconsole
-rwxr-xr-x. 1 ec2-user ec2-user 6.2K Sep 17 20:42 jcontrol
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jdb
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jdeps
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jhat
-rwxr-xr-x. 1 ec2-user ec2-user 8.0K Sep 17 20:42 jinfo
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jjs
-rwxr-xr-x. 1 ec2-user ec2-user 8.0K Sep 17 20:42 jmap
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jps
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jrunscript
-rwxr-xr-x. 1 ec2-user ec2-user 7.8K Sep 17 20:42 jsadebugd
-rwxr-xr-x. 1 ec2-user ec2-user 8.0K Sep 17 20:42 jstack

So if you type javac and it the command is not recognized then this implies that the JDK/bin is not on the PATH. Simple as that. It does not mean that the JDK is not installed on that host - it could be - it is just that JRE/bin is in the PATH and JDK/bin is not.

Community
  • 1
  • 1
Khanna111
  • 3,627
  • 1
  • 23
  • 25
1

When I execute the following on my box without JDK in the path

javac

I get;

The term 'javac' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:6
+ javac <<<<
    + CategoryInfo          : ObjectNotFound: (javac:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Since I have the runtime in my path when I do the following

java -version

I get;

java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

On my mac which has jdk on the path when I do javac

$ javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
...

In summary I run javac to see if I have the JDK active or not.

Jerome Anthony
  • 7,823
  • 2
  • 40
  • 31