Jump to content
  • Advertisement
Sign in to follow this  
Shashwat Rohilla

Is JVM needed to run every java program

This topic is 2563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Share this post


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

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?

Share this post


Link to post
Share on other sites

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?

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!