File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes is there a EXE file in java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "is there a EXE file in java ?" Watch "is there a EXE file in java ?" New topic
Author

is there a EXE file in java ?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
The Sun HotSpot VM -which is used since Java 1.3 if memory serves- takes measurements of which methods and classes are heavily/lightly used at runtime. Based on that it may actually decide NOT to compile a method, and to interpret it every time it gets called. It definitely does not compile everything at once at startup.
Other JVMs (IBM, Kaffe, SableVM...) may work differently.


Ping & DNS - my free Android networking tools app
jay nair
Greenhorn

Joined: Sep 13, 2005
Posts: 28
hi ,
i have just started learning java. what exactly happens when a java program is complied ? doest it make a Obj file ? and what happens when u run a java program , ? does it form a EXE file like in C or c++ ?

thanks in advance
Brad Cantrell
Greenhorn

Joined: Aug 27, 2005
Posts: 22
No its not precompiled, it is compiled during runtime by the virtual machine.

Which brings up a question of my own: I heard that Sun was working on this "just in time" thing where the VM would compile the entire code at once so it would run faster. Has anything been done with that?
Ray Horn
Ranch Hand

Joined: Oct 20, 2005
Posts: 39
Hi William,
Here are some links to answer your question and to help you learn more:

compiling & running Java

The Java Tutorial

Hope these help.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Just to be clear:

Java is pre-compiled. However, it is not pre-linked. When you create your .class files from your .java files, that is essentially the same as creating .o (or .obj) files from your .c/.cxx files. (There are differences, of course -- most notably a single .java file can produce multiple .class files -- but we won't get into those differences).

The biggest difference is what Java get compiled into. You do not compile to platform-specific machine languages. Instead, you compile to Java bytecode. The Java bytecode (the .class file) is identical on every platform because it is run through the Java Virtual Machine (JVM). You could think of the JVM as an interpreter for the bytecode, thus making Java both a compiled and an interpreted language. You get better performance than a standard interpreter, however, because you are interpreting things that are already parsed and (presumably) optimized by the compiler. You don't have to re-parse the human-readable code each time.

However, as pointed out above, even this was not necessarily fast enough for various applications. So Just In Time compiling was introduced. A platform that has a JIT compiler will produce machine-code for that platform at run time. As noted above, this compiling is optimized and is entirely beyond your control (unless you write your own JVM with JIT compiling...), so the usual recommendation is to not worry about it. Knowing about compiling to .class files and about what bytecode is and its functionality is more important than knowing about the JIT compiler.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is there a EXE file in java ?
 
Similar Threads
Why Java is slower?
invoking c exe from java
run exe in client sid
program running problem
running a java program