Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compiling Java code together with "virtual machine" 1

Status
Not open for further replies.

jianhuay

Programmer
Apr 11, 2001
13
AU
Hello everyone,

I heard Java code can be compiled together with Java virtual machine, that is the compiled byte code has a "virtual machine" in it, so that it can be run in a computer where there is no Java runtime installed. If so, I'd like to know how to do it. Can someone give me any hint?

Thank you in advance.

Jian
 
I have exactely the same question!
I also wanna know if I can make executables from my classes
(I work with jbuilder 6)
I used to work with VB and I remember that there you could make setup files from your program. I found that very easy.
Is there somthing similar in java ?

Thnx.
Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
You would have to target a specific architecture, becuase although the Java bytecode is machine-independent, the virtual machine is very dependent upon the target architecture. Effectively, you'd lose the platform independence of Java.

There may be specific tools for specific platforms, but I can't imagine there's a general-purpose tool for this.
 
I have seen a Windows IDE that can accomplish this. I can't remember off the top of my head what the name of it was, but I do remember that I found it via a search off of google, and I remember that it was free for 30 days or so. I would do a search fo "java exe" in google and see what that returns. Sorry I couldn't be of more help, but I do know that a tool like that exists.

-gc "I don't look busy because I did it right the first time."
 
Although I can completely understand compiling with a JRE, I can not understand why you would want to compile Java to .exe.
Can you explain why and maybe we can put you on a different path. The main reason you would want to use Java is for portability which you lose when you compile .exe. Not to mention why go through all those extra steps when you could use C++ or some other native language? It just doesn't make sense from a Java development point of view
 
While I would agree that this is probably a bad idea, it does have an upside, its going to run faster, and will be easier to launch. Bacon is probably right when he says that you should be using C++ if you are interested in writing os specific code, but if you already have your app built in JAVA, and you don't want to go through the trouble of re-writing your entire app, making an exe from JAVA code is an option.

-gc "I don't look busy because I did it right the first time."
 
Why,why,why ??? :)
I'll tell you why,
I do know C++ (linux and dos), but not visual C++, so making a beautiful application in windows is not a possibility (yet).
I want to compile java to an exe because I think it is annoying thay you can't just execute an applet by doubleclick (meanwhile the idea of a batch came up)
and due to the restrictions of an applet when it comes to files.
Actually I was thinking about the time I used VB and I could compile to a beautiful setup file, and I wondered if the same was possible in java. Meanwhile,someone explained me the idea behind the virtual machine and that I should make a jar file instead of an exe.

Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
Hello

First of all - I have no solution to your problem. I just want to warn you about a very "beautiful-on the first look" solution.

What you are NOT searching for is the old MS Visual J.
If you look at it first time - it is perfect. You are able to build nice GUI's in no time. Then compile everything from .exe to COM objects with it.
BUT: Even the highly portable class files that you produce do not run on any other system than Windows. And MS is not compiling YOUR code - it keeps exchanging classes from java.awt to ms.whatever without telling you.
So be warned. I had to work with it to build COM objects and it is no fun once you want your code to run on a real virtual machine. No wonder MS no longer sells it.

kaiDaniel
 
There is a easy-to-use software named "JToExe" that can be used to create an exe from java classes. you can dowload this software from download.com or from any other software library. but as some have said earlier, your application will become platform dependent. i am not sure that wether it will run without a virtual machine or not.
 
You mention that you can't start an applet by double-clicking and that there are VM-imposed restrictions on file access for applets. The first point is true for both Java applets and applications, but the second point isn't true for Java applications. Java applications running on the local machine have the same access to the file system as any other application.

There might also be a solution through file extension associations or batch files. That could solve your problem without you having to learn additional tools. One thing to beware of when considering compiling Java to native code is that the performance improvement may not be as much as you'd think. The application will still depend on the Java runtime environment, even if it statically links the runtime libraries, so your application may gain some time in loading, but not much in running.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top