Sign in to follow this  

Java, bytecode, and exe's

This topic is 4491 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

Today in computer science, my teacher asked if Java ever creates an executable file. I said no, because the Java compiler compiles the source into a .class file containing bytecode. She said that's true, but when the bytecode runs on the JVM, it creates an exe in memory. I don't think she's right, but I don't know exactly how the JVM works. I thought that it compiled and executed the bytecode on the fly, rather than all at once and storing the result in memory to execute. On large programs, that would seem rather unweildy. Does anyone know the real answer?

Share this post


Link to post
Share on other sites
Well... yes and no. It creates compiled code from the bytecode on the fly, but leaves that on-the-fly-created compiled code in memory as it finishes each piece (so it won't have to recompile for the next call of the same function). Over time, the entire program can be compiled. :)

Share this post


Link to post
Share on other sites
I would say that an "executable file" is more than compiled code... it includes stuff like imports from dll's, different sections such as code, constants, resources, etc...

Also, when I hear "exe" I usually assume its referring to a windows exe, which is a specific format for storing a binary executable. I'm pretty sure the java virtual machine doesn't generate all the headers and such exe's have.

Share this post


Link to post
Share on other sites

This topic is 4491 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.

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