Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Save java file as *.exe?

  • 15-11-2005 2:14pm
    #1
    Closed Accounts Posts: 27,857 ✭✭✭✭


    Hey folks,

    I'm just wondering if there's a way to save a java program as an executable? ie. not having to go into dos and through the whole java myProgram thing. It makes it a bit more professional to be able to do this.

    I found this, but it's a little hard to understand...
    http://forum.java.sun.com/thread.jspa?threadID=472032&tstart=90

    Anyone able to simplify it? I only know basic java (1st year in uni now).

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    i. There are install wizards - but the end product is quite bloated..

    ii. You could compile it as a native application but then it defeats the advantage of using Java..

    iii. Create a DOS .bat (Batch) file to run the commands that you would normally type into a DOS prompt .. (Advantage: saves you typing them manually.)

    iv. Provided you or your intended audience have a JAVA VM setup correctly: then an executable .jar will do the job (They simply double-click on the .jar and hey presto!)
    http://java.sun.com/docs/books/tutorial/jar/basics/


  • Closed Accounts Posts: 324 ✭✭madramor


    You have all you classes and packages in a folder called project

    project
    ie
    company
    gui
    (loads of classes)
    comms
    (loads of classes)
    actions
    (loads of classes)
    etc

    now you have a start class called StartEngine.class in
    the gui package

    so you go c:\projects\java ie.company.gui.StartEngine
    to run your project

    To create an executable jar
    1:
    create the manifest file in folder project
    create a file called mymanifest.mf
    with the 2 lines
    Manifest-Version: 1.0
    Main-Class: ie.company.gui.StartEngine
    2:
    create the jar file
    in cmd at c:\projects type
    jar cvfm myjar.jar mymanifest.mf *.classes

    this will create a file called myjar.jar
    and when double clicked it will run your project


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    I use a program called exe4J

    Website: http://www.ej-technologies.com/products/exe4j/overview.html

    It allows you to easily package your java software as an exe file. I dont believe this defeats the advantage of using Java as there is a lot more to java than portability such as rapid and easy development cycles. Most of the people I deal with run small businesses where all their systems run Windows and they have no intentions of moving to linux or other systems. These people want to use what is familar to them which are exe files not jar's bat's or class files so packaging makes sence. You can also give your exe an icon and display a splash screen while it loads.
    One thing is it displays a popup until you register it.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    However your using exe4J effectively locks them into windows even at a later date where they may need the software to run on another operating system.

    Average windows user has no clue whats behind the scenes. You can quite easily set up a batch file with a shortcut to it with an icon and your application can easily launch a splash screen. Or just have a self executing jar and shortcut to that.

    Most modern day java programs your average user wouldn't even know that it is java. Eclipse being a good example.


  • Closed Accounts Posts: 324 ✭✭madramor


    clearz wrote:
    These people want to use what is familar to them which are exe files not jar's bat's or class files so packaging makes sence.
    a jar is just a file that starts when you double click it like a exe
    clearz wrote:
    You can also give your exe an icon
    you can give any file an icon, that has nothing to do with it being
    an exe
    clearz wrote:
    display a splash screen while it loads.
    you can create your own splash screen in java


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    Hobbes wrote:
    However your using exe4J effectively locks them into windows even at a later date where they may need the software to run on another operating system.

    Average windows user has no clue whats behind the scenes. You can quite easily set up a batch file with a shortcut to it with an icon and your application can easily launch a splash screen. Or just have a self executing jar and shortcut to that.

    Most modern day java programs your average user wouldn't even know that it is java. Eclipse being a good example.

    I dont believe this to be true. Most of these people are never gonna use anything but Windows as their operating system. They strugle to boot up the system in the morning and log in. Even in the very rare case that someone might decide to use a different operating system then I could just supply them with the JAR version (For a small fee off course).
    What about the millions of programmers out there that program in C++ or VB or something that dosent run on a virtual machine as their main language. What would they do? I think people get hung up on the portability side of Java to much.
    Packaging as an exe basically saves my a load of phone calls wondering what this file is for and that file is for because someones secretary accidently deleted the .bat file or the shortcut file and I know because it has happened before to me.


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    madramor wrote:
    a jar is just a file that starts when you double click it like a exe
    I know it is but a lot of non-programmers out there dont know that. Packaging as an exe takes about 1-2 minns and makes things easier for the end user. And anything that is easier for the end user ultimately is easier for me by way of less support calls.
    madramor wrote:
    you can give any file an icon, that has nothing to do with it being
    an exe

    No you cant.
    madramor wrote:
    you can create your own splash screen in java

    I know you can do that but there really is no point. Most of the startup time with a Java app(unless its a very big app) is used in starting the virtual machine so a pure Java splash will not get displayed until after the VM gets started and the actual program will start 1-3 secs later. exe4J natively embeds the splash screen in the exe which shows straight away while the VM starts up.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    clearz wrote:
    Even in the very rare case that someone might decide to use a different operating system then I could just supply them with the JAR version (For a small fee off course).

    Ah ok, so your breaking portability to ensure more money later on. ;) Even so you are making more work for you where none needs exist.
    What would they do? I think people get hung up on the portability side of Java to much.

    Just making a java into an exe is total overkill as pointed out. Jars can run exactly like an EXE (double click) now.

    If people are randomly deleting stuff then it is a totally seperate problem and having an EXE isn't going to change it.
    Originally Posted by madramor
    you can give any file an icon, that has nothing to do with it being
    an exe

    No you cant.

    Hes right you can. Hes making the point because you were going on that you could put an icon onto the exe.

    As for splashscreens. Like I said look at Eclipse. It throws a splash screen up instantly while loading and that is written in java.


  • Closed Accounts Posts: 324 ✭✭madramor


    clearz wrote:
    No you cant.
    1:
    how to change the icon for a jar file

    Control Panel -> Folder Options -> File Types ->
    Select Executable Jar Files
    Click Advanced Button
    Click Change Icon Button and select the new icon.

    2:
    Most exe's || jars are linked to using a shortcut
    from desktop or start menu for which you can easily
    change the icon.


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    madramor wrote:
    1:
    how to change the icon for a jar file

    Control Panel -> Folder Options -> File Types ->
    Select Executable Jar Files
    Click Advanced Button
    Click Change Icon Button and select the new icon.

    2:
    Most exe's || jars are linked to using a shortcut
    from desktop or start menu for which you can easily
    change the icon.

    1. There is a difference between giving an application an icon and changing the icon for an entire file type.

    2. I am aware that you can give a shortcut an icon but as I said in my post above desktop shortcuts get deleted and then they come crying to me about how there program stoped working.

    3. I dont want a debate. I have my methods and you have your methods. I am simply stating that spending 2 minns packaging a Java app as an exe for an end user that you know will only be using it on a Windows box is not only neater but will probably save you hastle in the future.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    clearz wrote:
    2. I am aware that you can give a shortcut an icon but as I said in my post above desktop shortcuts get deleted and then they come crying to me about how there program stoped working.

    I am curious then how do they run the EXE? Do you put the EXE on the desktop? Or use a shortcut?


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    I understand what you are getting at but as far as I can see.

    Average Windows user + exe = good
    Average Windows user + jar and/or bat = not as good.


  • Closed Accounts Posts: 324 ✭✭madramor


    clearz wrote:
    I understand what you are getting at but as far as I can see.

    Average Windows user + exe = good
    Average Windows user + jar and/or bat = not as good.

    Can you give me 1 example, where a users can do something
    that will mess up a jar file that would not mess up a exe file
    I honestly don't see the difference


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    clearz wrote:
    I understand what you are getting at but as far as I can see.

    Thing is I can't understand what you are getting at. :/


  • Registered Users, Registered Users 2 Posts: 1,745 ✭✭✭swiss


    Average Windows user + exe = good
    Average Windows user + jar and/or bat = not as good.
    You're assuming Average Windows user = dumb.

    In that case, most users are going to ignore file extensions and just double click on what "seems" to be the right icon.

    If you're insisting on a .exe file, wouldn't it just be better to make an executable that simply runs your jar?

    edit: Oh, and as has already been pointed out, jars are executable. I don't know offhand how you would make an .exe that would simply run your jar. Seems like a google question to me though.


  • Registered Users, Registered Users 2 Posts: 2,934 ✭✭✭egan007


    windows by default don't show the extention amyway -
    so the Average windows user would not know / care what an exe was.

    You can use Java Webstart to start apps - search on sun.com
    Java should stay away from .exe to maintain it's cross platform operability.

    Assign an icon if you want - as was mentioned any icon can be assigned for usability.

    If you pretty much stay away from clearz windows based approach your rewards will be great. Every time someone stays away from this approach windows looses a little bit more. Sorry clearz but resrticting a multiplatform application to one platform is terrible practice.


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    swiss wrote:
    You're assuming Average Windows user = dumb.

    I never said that. Just because some end users can barely get the computer switched on does not make them dumb. It simply means they lack knowlege of computer systems. But a programmers job should be to make the system as userfriendly as possible.
    egan007 wrote:
    If you pretty much stay away from clearz windows based approach your rewards will be great. Every time someone stays away from this approach windows looses a little bit more. Sorry clearz but resrticting a multiplatform application to one platform is terrible practice.

    I dont get you. The applications that I compile into exe's are not ment to be "multiplatform application's". If they where ment to run on multiple platforms then I simply wouldnt compile into an exe. Just because I use the Java language does not make it a multiplatform application. So what your saying is if I used C++ or a .net language to make the same app then it would be ok for it to be an exe but as soon as I use java I have to adhere to the write once run anywhere philosophy. Rubbish.
    Anyway you all do what you think is right and ill spend my 2 minns extra making my exe files.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    This is my own personal opinion on it. (not related to Clearz reason afaik).

    exe4J is a throwback to when Java was young.

    Basically a java app was horrible to install. You had to supply a JVM, it had to be the right JVM.

    It was slow and Java had a stigmata of "not being a real program".

    So disguising it as an EXE gave the impression it was a compiled EXE when it wasn't. You had to use a command line to run it and paths, etc had to be set up.

    There was a similar tool for BAT files back in the DOS days. You could compile a batch file into an EXE (basically what the operating system did anyway) as batch files were not considered real programs.


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    You are deffently right Hobbes. I and many others I know have always had the thing of java "not being a real program". And maybe even that has some unconscious role in me compiling to an exe.

    I remember before I started college I used to mess arround with C creating small programs and I loved the ability it gave me to get down and dirty with the system. Then I started college and Java is what we were thought. I hated the idea of Virtual Machines and this language managing what I wrote. It wassnt what I liked about programming. I would have been more happy studying assembly for 4 years.

    Nowadays time=money and Java allows me to write an application in a fraction of the time that I could do it in C so its my language of choice.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Virtual machines have come a long way though. For example the latest JVMs will monitor the code as its running and rewrite the code in memory to be faster. So the longer a java app runs the better it gets. Something you can't do with an EXE.


  • Advertisement
Advertisement