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.

5
  • 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. Commented Jul 18, 2015 at 18:09
  • possible duplicate of What is the difference between JDK and JRE? Commented Jul 18, 2015 at 18:10
  • 1
    Eclipse-for-Java has its own Java compiler, it doesn't need the javac from JDK. See stackoverflow.com/questions/3061654/… . Commented Jul 18, 2015 at 20:43
  • As i mentioned above i have run the program from bin directory. Commented Jul 19, 2015 at 4:35
  • @dave_thompson_085 you should make that an answer so that Saran can accept it. Commented Aug 25, 2015 at 4:23

3 Answers 3

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).

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

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 why are you manually copy pasting the class files. Better remove the JRE and install the JDK. It contains JRE as well.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.