Sign in to follow this  
Shashwat Rohilla

Is JVM needed to run every java program

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Danny02    279
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.

Share this post


Link to post
Share on other sites
[quote name='rip-off' timestamp='1310544062' post='4834669']
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.
[/quote]

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

[b]He should be able to run (not install) the java program without JRE, by just double clicking the *exe. Is it possible.
[/b]How to do that?

Share this post


Link to post
Share on other sites
SiCrane    11839
You might want to read [url=http://www.excelsior-usa.com/articles/java-to-exe.html]this[/url].

Share this post


Link to post
Share on other sites
Mossen    114
[quote name='Shashwat Rohilla' timestamp='1310540534' post='4834647']
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?
[/quote]

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?

Share this post


Link to post
Share on other sites
Antheus    2409
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.

[quote]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.

Share this post


Link to post
Share on other sites
issch    479
[quote name='Danny02' timestamp='1310548679' post='4834716']...they are experimental and u will have a lot of problems using them...
[/quote]
[url="http://www.excelsior-usa.com/jet.html"]Excelsior JET[/url] (which SiCrane mentioned) is far from experimental and supposedly generates very well performing native code executables.

Share this post


Link to post
Share on other sites
[b]Its clear now!
[/b]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 !

[b]But still, do we have *.exe in Java (even if it includes JVM inside it)?
Does Eclipse create *.exe?[/b]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this