Valhalla Legends Archive

Programming => General Programming => Java Programming => Topic started by: iago on December 06, 2003, 04:14 PM

Title: Standalone .exe's?
Post by: iago on December 06, 2003, 04:14 PM
How do you make standalone .exe files in Java? I know I've seen them before, and it would be nice to be able to.

Thanks!
Title: gcj can do it
Post by: Kp on December 06, 2003, 06:52 PM
(and does so by default).  Don't know if there are other things which can do so.  Note that, as a native exe, it won't have the portability of a normal .class file.  Also, it is probably not possible to decompile it back into the original .java file (however, a .class file can supposedly be fully decompiled).
Title: Re:Standalone .exe's?
Post by: Hostile on December 06, 2003, 07:32 PM
Yes, its more then possible to decompile java classes, which is quite obvious as to why. I think its even a feature in JBuilder iirc. You can also disassemble classes though javap which is provided with JDK. Yes, obviously there are ways to make .exes with java, however as Kp noted its not by the terms "100% Pure Java", which contrary takes away all of javas portability and there for needs to be recompiled on different platforms. If you're looking for a way to execute java as a standalone then theres an alternative to not taking away its portability, use .jar files. If system paths are configured correctly can use a jar file to execute a class thats archived inside the jar file (which is its main purpose).
Title: One of the advantages of using gcj to build native
Post by: Kp on December 06, 2003, 09:15 PM
...is that you can optimize the code.  Native code tends to run faster than bytecode, especially when you let the optimizer take a crack at it.  If you run into some pre-existing Java code that you really need to perform well, compiling it native may be the solution if you don't have time to do the sensible thing (porting it to a language where speed was a design consideration ;)).
Title: Re:Standalone .exe's?
Post by: iago on December 07, 2003, 08:21 AM
My main reason is that I want to be able to show programs to my friend/whatever, but if he can't run .class files easily (perhaps doesn't have the stuff installed)
Title: Re:Standalone .exe's?
Post by: Kp on December 07, 2003, 11:24 AM
I'm pretty sure most Windows OSes will have some sort of Java VM installed already (whether this is good or not is another issue...)
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on December 07, 2003, 04:56 PM
Quote from: Kp on December 07, 2003, 11:24 AM
I'm pretty sure most Windows OSes will have some sort of Java VM installed already (whether this is good or not is another issue...)

No.
Title: Re:Standalone .exe's?
Post by: iago on December 07, 2003, 05:02 PM
By default, windows can't do anything with .class files afaik.
Title: Well ...
Post by: Kp on December 07, 2003, 05:57 PM
... without having explicitly installed it on any of them, all the computers I have access to have a Java VM (java.exe) already installed.  It's not associated with .class in the Windows shell, so Windows doesn't think it can do anything with them, but you can use it to run the class files from the command line.
Title: Re:Standalone .exe's?
Post by: iago on December 08, 2003, 02:49 AM
... which is why I want to be able to make .exe's instead of having .class files.  It's fine if it's still bytecode+VM, as long as they don't need installed software to use it.
Title: Re:Standalone .exe's?
Post by: j0k3r on December 08, 2003, 06:41 AM
If you had a .class file, and had VM installed, would it just open a window and run it? Because I'm pretty sure about 90% of the computers out there have VM installed.
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on December 08, 2003, 08:16 AM
1) I'm pretty sure they don't have the VM
2) Clicking a class file won't do anything, however, an executable JAR would do something if the VM is installed.
Title: Re:Standalone .exe's?
Post by: iago on December 08, 2003, 11:36 AM
Quote from: j0k3r on December 08, 2003, 06:41 AM
If you had a .class file, and had VM installed, would it just open a window and run it? Because I'm pretty sure about 90% of the computers out there have VM installed.

90% just doesn't cut it all the time :P

Title: Re:Standalone .exe's?
Post by: Hostile on December 08, 2003, 05:57 PM
Quote from: St0rm.iD on December 08, 2003, 08:16 AM
1) I'm pretty sure they don't have the VM
2) Clicking a class file won't do anything, however, an executable JAR would do something if the VM is installed.

I already said that, and almost any computer with a webbrowser has the Java VM. iago, I think you should just consider some sort of executable solution(.jar or .exe) or some more inconvienent alternative, like an applet.
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on December 08, 2003, 07:01 PM
Quote from: Hostile on December 08, 2003, 05:57 PM
Quote from: St0rm.iD on December 08, 2003, 08:16 AM
1) I'm pretty sure they don't have the VM
2) Clicking a class file won't do anything, however, an executable JAR would do something if the VM is installed.

I already said that, and almost any computer with a webbrowser has the Java VM. iago, I think you should just consider some sort of executable solution(.jar or .exe) or some more inconvienent alternative, like an applet.

Um no. The Java VM you're talking about works for Java 1.1...and I don't think they usually support standalone JARs or apps, either.
Title: Re:Standalone .exe's?
Post by: iago on December 08, 2003, 09:45 PM
Quote from: Hostile on December 08, 2003, 05:57 PM
Quote from: St0rm.iD on December 08, 2003, 08:16 AM
1) I'm pretty sure they don't have the VM
2) Clicking a class file won't do anything, however, an executable JAR would do something if the VM is installed.

I already said that, and almost any computer with a webbrowser has the Java VM. iago, I think you should just consider some sort of executable solution(.jar or .exe) or some more inconvienent alternative, like an applet.

I AM considering an executable solution, .exe in particular.
Title: Re:Standalone .exe's?
Post by: Hostile on December 09, 2003, 12:30 AM
Quote from: St0rm.iD on December 08, 2003, 07:01 PM
Um no. The Java VM you're talking about works for Java 1.1...and I don't think they usually support standalone JARs or apps, either.

Well, prove it. I'm not sure where exactly they're bundling the Java VM and RTE so if you have somewhere with this info please share~. Also, I remember sky mentioning that they stopped bundling the Java VM with Internet Explorer, this was somewhat recent (6.0) but not sure how thats all going about.
Title: Re:Standalone .exe's?
Post by: j0k3r on December 09, 2003, 06:12 AM
Quote from: Hostile on December 09, 2003, 12:30 AM
Quote from: St0rm.iD on December 08, 2003, 07:01 PM
Um no. The Java VM you're talking about works for Java 1.1...and I don't think they usually support standalone JARs or apps, either.

Well, prove it. I'm not sure where exactly they're bundling the Java VM and RTE so if you have somewhere with this info please share~. Also, I remember sky mentioning that they stopped bundling the Java VM with Internet Explorer, this was somewhat recent (6.0) but not sure how thats all going about.
Does it even matter? You can download and it install it for free and with no hassle (once a java applet tries to be executed and you don't have VM, it will install from the website, or atleast at school it does).
Title: Re:Standalone .exe's?
Post by: SNiFFeR on December 09, 2003, 08:36 AM
We just got these books in, the name of the books are Java™ Software solutions for the AP Computer Science.
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on December 09, 2003, 03:01 PM
Quote from: j0k3r on December 09, 2003, 06:12 AM
Quote from: Hostile on December 09, 2003, 12:30 AM
Quote from: St0rm.iD on December 08, 2003, 07:01 PM
Um no. The Java VM you're talking about works for Java 1.1...and I don't think they usually support standalone JARs or apps, either.

Well, prove it. I'm not sure where exactly they're bundling the Java VM and RTE so if you have somewhere with this info please share~. Also, I remember sky mentioning that they stopped bundling the Java VM with Internet Explorer, this was somewhat recent (6.0) but not sure how thats all going about.
Does it even matter? You can download and it install it for free and with no hassle (once a java applet tries to be executed and you don't have VM, it will install from the website, or atleast at school it does).

Granny can't do this, and 56k'ers don't want to wait.
Title: Re:Standalone .exe's?
Post by: j0k3r on December 09, 2003, 03:20 PM
56k'ers don't matter and I don't see what use a granny has for Java.
Title: Re:Standalone .exe's?
Post by: iago on December 09, 2003, 03:26 PM
Maybe she wants to use a cookbook, and are you saying that spht and other people who don't live in areas with highspeed don't matter?
Title: Re:Standalone .exe's?
Post by: j0k3r on December 09, 2003, 04:27 PM
Quote from: iago on December 09, 2003, 03:26 PM
Maybe she wants to use a cookbook, and are you saying that spht and other people who don't live in areas with highspeed don't matter?
No, I'm saying that it doesn't matter if it takes forever for them (not speaking from their point of view ofcourse), you download it once and you're good to go, so if you have 56k might as well just put up with it cause nothing is going to change (if you can't get 56k).

The ones who don't matter are the AOL'ers in major cities who whine about 56k but don't do anything about it.

Screw the grandma, she falls into either category and doesn't deserve her own, and if she has 56k, it's her own choice (or not) to live with it.
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on December 09, 2003, 04:34 PM
Or you just can't admit defeat.
Title: Re:Standalone .exe's?
Post by: j0k3r on December 09, 2003, 06:02 PM
STOP MAKING FUN OF ME
/me runs

Anyways, iago you find a way to do it yet?
Title: Re:Standalone .exe's?
Post by: iago on December 09, 2003, 06:11 PM
Quote from: j0k3r on December 09, 2003, 06:02 PM
STOP MAKING FUN OF ME
/me runs

Anyways, iago you find a way to do it yet?

No, and I haven't been trying.  Too much work to do right now for school and such.
Title: Re:Standalone .exe's?
Post by: Hostile on December 09, 2003, 07:49 PM
j0k3r... Ok, as flawless as your idea is and I sure to some aspect I know this is also fine, thats just about the worse point of view you could have as far as its concerned. Yes, I know where to download it and install it in less then a minute but I don't think everyone else can do the same, and its quite pointless to expect them to know how to either. I can honestly say I went through a stage where I thought I was a god because I knew more then almost everyone I would run into in real life about computers, but this doesnt last very long. As soon as you figure out that no matter how much you know in your own little world, you tend to lose that as soon as someone comes along talking about something you have no clue about  :P Grandma might not know how use a computer, but she could probably kick your ass in whatever she did in her time ;)
Title: Re:Standalone .exe's?
Post by: j0k3r on December 09, 2003, 09:08 PM
That's because she's been doing it for 50-someodd years...

I thought the VM download automatically popped up when an applet tries to run and you don't have VM installed.
Title: Re:Standalone .exe's?
Post by: Dark-Feanor on December 10, 2003, 09:31 PM
There are many applications on the market that do this for you. Compilers to stand alone .exes. Some of them work for one operating system (so you would have to get a different compiler for each OS N.B. no source change required) and some of them work for all, but they can burna  hole in your wallet.
Title: Re:Standalone .exe's?
Post by: hismajesty on December 11, 2003, 08:27 AM
Quote from: DaRk-FeAnOr on December 10, 2003, 09:31 PM
There are many applications on the market that do this for you. Compilers to stand alone .exes. Some of them work for one operating system (so you would have to get a different compiler for each OS N.B. no source change required) and some of them work for all, but they can burna  hole in your wallet.

That's what pirates are for :P
Title: Re:Standalone .exe's?
Post by: Hostile on December 11, 2003, 09:55 PM
j0k3r, you're developing a habit of totally missing someones point. I suggest either work on improving your reading skills or getting your eyes examined... perhaps its just your comprehension or denial of being stupid? Either way, we already found a great free compiler for making java standalone executables and the best place to get the VM is on www.java.com so lets leave it at that. :P
Title: Re:Standalone .exe's?
Post by: iago on January 19, 2004, 11:55 AM
http://download.com.com/3000-2417-1987574.html?tag=lst-0-1

Apparently, this can run .class files as if they were normal .exe files.  

- Thanks to MorsRedigo for finding this - (I promised I'd give him credit :))
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on January 19, 2004, 02:49 PM
That's no different than an executable JAR...except worse.
Title: Re:Standalone .exe's?
Post by: iago on January 19, 2004, 03:09 PM
How do you make a jar executable?  I didn't even know jar's existed until just recently.

Note: he needs it for a windows machine.
Title: Re:Standalone .exe's?
Post by: Banana fanna fo fanna on January 19, 2004, 06:27 PM
Cross platform my friend :)

Look up the docs for the jar tool; my commands might be wrong, haven't done java in a loooong time.


Basically, you have a bunch of .class files for your application. One of them has a main() method. You create a special "manifest" file, which looks like:

Main-class: mypackage.MyClass


Remember the trailing endline! Then execute something like:

jar cvfm MyJarFile.jar manifest packagename