📌 To summarize:
Purpose You Need Tools Included Just run Java code JRE JVM, Libraries Write + run code JDK JRE + Compiler + Tools
Purpose | You Need | Tools Included |
---|---|---|
Just run Java code | JRE | JVM, Libraries |
Write + run code | JDK | JRE + Compiler + Tools |
✅ 1. Can you run Java code with only JRE?
Yes, if you already have compiled .class
or .jar
files.
📦 Example:
If someone gives you Hello.class
or Hello.jar
, and you have JRE, you can run it like this:
✅ JRE includes java
(to run programs)
❌ JRE does NOT include javac
, which is used to compile .java
files
❌ 2. Can you compile Java code or create JAR files with only JRE?
No, because JRE does not have the compiler or packaging tools.
You cannot do:
Those tools come only with JDK.
📦 Summary
Action | JRE ✅ / ❌ | JDK ✅ / ❌ |
---|---|---|
Run .class file (java ) | ✅ | ✅ |
Run .jar file | ✅ | ✅ |
Compile .java file | ❌ | ✅ |
Create .jar file | ❌ | ✅ |
🔧 What You Need:
Use Case | You Need |
---|---|
Just run an existing .jar or .class app | ✅ JRE is enough |
Write Java code, compile, and package as JAR | ✅ JDK is required |
✅ Conclusion:
🔹 You need JDK if you're developing Java apps
🔹 You only need JRE if you're just running precompiled Java apps (like Minecraft, Jenkins, etc.)
No comments:
Post a Comment