• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

how to make an exe

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to make an exe file .. does it make with the jar or class........
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want an exe?? A jar file can be executed by the user by double clicking on it (or hooking it to an icon) or you can create a .bat or .sh file that sets the path and classpath and invokes the application with whatever parameters that you want.
But neither of those is ACTUALLY an exe. If you DO make an exe out of your Java code, then you will break the platform independance which is one of the main reasons for using java to begin with.
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to make an exe bcos i make a game .. its a chess.. so bat file needt class path of jdk ..but exe run by the vituall mechine ...
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you are getting the terminology wrong.
A JVM does NOT run an exe. exe files are binary files. The JVM interprets class files (which can be "zipped" into JAR files) which are NOT binaries. They are bytecode files.
If you use javac on a .java file you will get a .class file out. You can later use the jar utility to jar your .class files into a java archive (jar).
You can execute your game using either the class files or the jar files.
Normally you would run the class file that contains the main method like:
>java game
and it would look for game.class to execute.
[ January 13, 2003: Message edited by: Cindy Glass ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this thread is very interesting (at least to me)... i have written a bit of code that takes some files and zips them up. later on they get displayed on the web.
my customer would like to be able to download them as "exe" files, in other words, self extracting files. i don't think they would care whether they were jar files or .exe files, as long as the user didn't have to have a zip program installed.
i've been looking at trying to create exe files for this reason, i hadn't thought about jar files. i guess this is why there isn't anything in the api about creating exe files...
i was going to ask if anyone had any code that did this, or had some clue api-wise as to some way to make an exe, but i guess i need to look at the jar thing and see what i can come up with.
thanks a lot, a lightbulb just turned on.
p.s. if you have a line of code that shows how to do the jar thing, it won't hurt my feelings or anything...
update: actually it occurs to me, do jars launch themselves like a self extracting zip / exe file in the absence of some sort of installed zip program? we are in all likelihood talking about windows machines.
*scratches head*
my ignorance is sure showing. i love being clueless, it makes life very surprising!
[ March 25, 2004: Message edited by: John Vaughan ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John, assuming you've set your environment to point to your java/bin directory, go to your command prompt and type "jar".
That will display information on how to use the java archiving tool.
As for jar files acting like exes on a Windows platform, I'm afraid I can't help you there as I use Linux.
 
John Vaughan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks wayne, i'm looking into it now. i see there is a whole separate class for jars in java.util. interesting. which means i'll have to rewrite a bunch of stuff. it may be a moot point now though, my customer says "jar files? what the heck are jar files?"
so it looks like it will be good old zip files for us.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jar files are not really "self-extracting files". They execute without extracting. You just have to make sure that your mime type is set up.
If you go in Internet Explorer to Tools/Folder Options/File Types and scroll down to find the jar extension, it should already be set up to execute a jar file. If not then you just add it as an extension type and point it at the java file to execute. This is what my file type option says to do with .jar files when double clicked:
open
C:\Program Files\JavaSoft\JRE\1.4\bin\javaw.exe -jar %1
Of course what I think that you are really talking about is an installation tool. There are programs out there like InstallSheild, and InstallAnywhere that bundle up all your java files, resource files, perhaps a .bat file to kick off the application, the jre if you want, etc and create a self-extracting zip file for the user to download. You can set it up to create an icon, install java if java is not already installed etc.
We use InstallSheild to create such a file, make it available on a web page, and then the end user can self install the application. The application itself still executes as a jar file or out of a bat file after it is installed.
Oh and here is a tutorial about jar files - Sun Jar Tutorial
[ March 25, 2004: Message edited by: Cindy Glass ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you (cindy) use

your java-program will get the arguments, you pass.
Which arguments?
If you mark 3 files a.f, b.f, c.f with your mouse and move them to your foo.jar, your Foo.main (String args[]) is called with

How convenient!
But if you (ali) ONLY ship your game as selfex, mac- and unix-users won't find it convenient, 'cause they cannot use it. Consider both, exe and zip/jar.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, if you just double click a jar file, windows will pass that file name to this line of code, and it will execute. That is the ONLY purpose for declaring a mime type.
This has nothing to do with how I would actually install a program. Personally I always create .bat files and connect them to an icon for the user to click. With the .bat file I can redirect the path and classpath and name as many input parameters as I want, and the user still only needs to click one thing.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..
I'm also making a game .. and i want it to download easily on anyone's computer easily.. what's the best way? what does the installation requires??
another thing, I still dont know how to deal with jar files..
i downloaded something that can be run through a jar file?? what should i do? what is the class path? how can i create this .bat file?
They may seem stupid and repeated questions, so if these things were discussed before.. just give me an url
1000000 thx
[ March 26, 2004: Message edited by: Saeed Meerkhan ]
[ March 26, 2004: Message edited by: Saeed Meerkhan ]
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!