3

I have installed JRE in my machine and downloaded Eclipse IDE and started to work on that IDE.

I have read from some blogs like Without JDK we can't compile the java program but i can able to run program/application in eclipse IDE.

Then in some other blogs gave me information like eclipse will have own JDK so try to run in command prompt to get know information. When i try to compile the program in bin folder(C:\Program Files\Java\jre7\bin) via command prompt it says javac couldn't recognize. I thought it's because of compiled class file is missing as JDK is not installed so i have copied the project from Eclipse IDE with class file and try to run the program it says couldn't find or load main class filename.java.

Even i have set environment variable as Java_home for the JRE bin path.

Pls explain JDK and JRE difference in brief to me.

Saran
  • 167
  • 2
  • 3
  • 11
  • From which directory did you run the command? Which command exactly did you run? By the looks of it, it seems your run the command from the wrong directory or you set your classpath incrrectly. Please provide more information. – Turing85 Jul 18 '15 at 18:09
  • possible duplicate of [What is the difference between JDK and JRE?](http://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre) – ganeshvjy Jul 18 '15 at 18:10
  • 1
    Eclipse-for-Java has its own Java compiler, it doesn't need the `javac` from JDK. See http://stackoverflow.com/questions/3061654/what-is-the-difference-between-javac-and-the-eclipse-compiler . – dave_thompson_085 Jul 18 '15 at 20:43
  • As i mentioned above i have run the program from bin directory. – Saran Jul 19 '15 at 04:35
  • @dave_thompson_085 you should make that an answer so that Saran can accept it. – CrazyPyro Aug 25 '15 at 04:23

3 Answers3

5

I understood the concept now.

Application is running in eclipse even without JDK installation as eclipse has its own compiler and JRE installed in my machine.

Copy of project from Eclipse IDE with class file is throwing error like 'couldn't find or load main class filename.java' because runtime environment couldn't find the class file as Javac compiler and Eclipse compiler class will be different so content will be different. So java interpreter couldn't find the class file of eclipse compiler class file(As similar to serialization concept).

Saran
  • 167
  • 2
  • 3
  • 11
3

Not possible to compile your java code in absence of JDK. javac , the java compiler, and other Java Development related binaries are available in the JDK only not in JRE.

For Getting Differences between JRE and JDK , you can refer here.

Community
  • 1
  • 1
AnkeyNigam
  • 2,810
  • 4
  • 15
  • 23
  • Yeah that's correct without JDK cannot compile the program but even JRE is not running after pasting the all class files in the directory.May i know the reason. – Saran Jul 19 '15 at 04:37
  • @Saran why are you manually copy pasting the class files. Better remove the JRE and install the JDK. It contains JRE as well. – AnkeyNigam Jul 19 '15 at 04:45
0

The JDK, or Java Development Kit, allows commands such as `java` and `javac`. The JDK is required to develop and run Java applets and applications.

The JRE is used to run Java programs. It is required to run any Java programs.

This might help: https://stackoverflow.com/a/29160633/6423975

Community
  • 1
  • 1
coder97
  • 17
  • 10