Sorry for the stupid question, I'm just beginning to learn Java. Can it be compiled into a .exe to be run on another computer, or is it only for computers with a JVM?
-
4See this question: stackoverflow.com/questions/2338724/…P.T.– P.T.2011-09-27 20:54:19 +00:00Commented Sep 27, 2011 at 20:54
-
gcc.gnu.org/javaBrandon Moretz– Brandon Moretz2011-09-27 20:54:50 +00:00Commented Sep 27, 2011 at 20:54
-
1Doesn't Java by definition require the JVM?David Heffernan– David Heffernan2011-09-27 21:01:36 +00:00Commented Sep 27, 2011 at 21:01
-
1@Walkerneo: for an exe you need a whole Windows operating system while just a JVM is sufficient on Unix/Mac/Smartphones/etc (and is often already embedded/preinstalled in many of the machines nowadays; at least, the coverage of JVM is higher than coverage of Windows).BalusC– BalusC2011-09-27 21:23:49 +00:00Commented Sep 27, 2011 at 21:23
-
1@Walkerneo, Because Oracle(Sun) provide a JVM implementation for every industry architecture. If a system isn't large enough to get Oracle's attention, then it is possible for the system developer to adapt or build a JVM from the JLS. Notably, Apple was typically behind in JVM version since they performed secret specific modifications to the JVM Sun supplied and didn't want to share, meanwhile Microsoft was prohibited from modifying the Windows JVM after they tried to roll a Windows specific Java language J++.Tim Bender– Tim Bender2011-09-27 21:25:02 +00:00Commented Sep 27, 2011 at 21:25
|
Show 7 more comments
2 Answers
Not exactly. You can bundle a JRE with your executable, which is kind of like the same thing. Embedding a JRE is one approach offered by launch4j.
There are third party projects that will allow you to do this. A free one is http://gcc.gnu.org/java/ . I don't believe it's officially supported by Java though, but it's also gnu, who happen to know a thing or two about compilers.
There is also http://www.excelsior-usa.com/jet.html which is a paid product, but supports up to Java 6.
3 Comments
Heisenbug
even it it seems to be compiled, it's still interpreted.
corsiKa
My understanding is that excelsior is completely compiled, not linked like gcc java.
Andy Thomas
There's also exe4j.