Is JVM needed to run every java program

Started by
8 comments, last by rip-off 12 years, 9 months ago
I want to create a Java program.
The program is converted into bytecode and then depeding on the machine, it is run by JIT.
But still *.exe is not created.

So even after deploying a java program, do I need JVM to run it.
Can't I generate its *exe based on the machine architecture?
Advertisement
Generally, you need a JRE. A common option is to include a JRE in your installation. Another option might be to use a compiler like GCJ.
Sure there are some experimental compilers that let u compile java directly to machiencode, but why would you?
First of all they are experimental and u will have a lot of problems using them,
sencondly the JVM is such hightech machiene that you probably will get way worse performance.

Generally, you need a JRE. A common option is to include a JRE in your installation. Another option might be to use a compiler like GCJ.


Ok I will include that; but will it create *.exe file after installation?
How the application will run?
Do I have to use 'java sample.class' to run the program?
What if I want to avoid this and deploy the program to a non-technical person?

He should be able to run (not install) the java program without JRE, by just double clicking the *exe. Is it possible.
How to do that?
You might want to read this.

I want to create a Java program.
The program is converted into bytecode and then depeding on the machine, it is run by JIT.
But still *.exe is not created.

So even after deploying a java program, do I need JVM to run it.
Can't I generate its *exe based on the machine architecture?


The short answer is, yes, in general, you need a JVM to run a program written in Java.


But the bigger question is, if you are trying to generate an *.exe, why are you using Java?
The main reason no such tools exist and why it's effectively no possible is legal.

Java is complex ecosystem, but some crucial parts are essentially proprietary to what is now Oracle. So even if you manage to overcome all the technical hurdles (which means your executable must contain JVM), you cannot do without the JDK or SDK packaged classes, since those aren't redistributable or may not be modified. The open source versions and alternate implementations however are not complete, again due to licensing issues. Also see the recent Google/Oracle legal fight over Java.

Can't I generate its *exe based on the machine architecture?[/quote]
Yes, that is possible (see Eclipse).

But it still requires JVM for reasons mentioned above.
...they are experimental and u will have a lot of problems using them...

Excelsior JET (which SiCrane mentioned) is far from experimental and supposedly generates very well performing native code executables.
Its clear now!
I think we don't need to create *.exe, we can have a batch file which will execute the *.jar file
Double-clicking it will run the application. Thats what I wanted.
Thanks all !

But still, do we have *.exe in Java (even if it includes JVM inside it)?
Does Eclipse create *.exe?
What part of the solutions described in SiCrane's link doesn't work for you?

This topic is closed to new replies.

Advertisement