Results 1 to 13 of 13
  1. #1
    CuppaCoffee's Avatar
    CuppaCoffee is offline Member
    Join Date
    Jan 2012
    Location
    Canada
    Posts
    80
    Rep Power
    0

    Default How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Quick question (hopefully). I've finished a program. It's done and freshened up and had its finishing touches and is ready to launch. However, I don't want to have to open Dr Java, or Eclipse to run it. I'd like the program to run without users being able to see the code (like a normal program), through a desktop shortcut or launcher. How would I be able to do this? Hopefully this is enough information for this question to be answered.

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Create an executable jar. Many (most?) systems with Java installed will then be able to run it by double clicking it. You could also include a shell script or batch file to start if double clicking fails. And if you're using Maven, there's a plugin to build an OSX app bundle... though I've never had much luck with it, and ended up coding Apple Java Extensions integration by hand.
    Get in the habit of using standard Java naming conventions!

  3. #3
    CuppaCoffee's Avatar
    CuppaCoffee is offline Member
    Join Date
    Jan 2012
    Location
    Canada
    Posts
    80
    Rep Power
    0

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    So if I were to create an executable jar, how would I go about doing that..?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,912
    Rep Power
    5

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    I would suspect that most IDE's support that. I know Eclipse does. However, if you must do it manually then read about jar files in the tutorials in my signature. Go to the Really Big Index and scroll down until you hit the section on Jar files.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    CuppaCoffee's Avatar
    CuppaCoffee is offline Member
    Join Date
    Jan 2012
    Location
    Canada
    Posts
    80
    Rep Power
    0

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    I never knew Eclipse had a function like that. I think that would be my main alternative before I try anything else. I guess it'd be too much to ask how it's done in Eclipse, so I'll look up how to do it in Eclipse first before I ask any more questions, thanks (I'll still use your sig for future references, much apprciated!).

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    I find the Eclipse way a bit obscure myself, Netbeans builds one without asking as part of its project build cycle.

    I use Maven myself to automate such things inside and outside of Eclipse, but that may be a step too far at this point in your learning process.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,912
    Rep Power
    5

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Under File, go to export...
    Then choose runnable Jar file. This does work but it has limited functionality. And interrogating regular jar files and manipulating them under Eclipse is almost non-existent. One of these days I may write a plugin.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Quote Originally Posted by jim829 View Post
    Under File, go to export...
    Then choose runnable Jar file. This does work but it has limited functionality. And interrogating regular jar files and manipulating them under Eclipse is almost non-existent. One of these days I may write a plugin.
    Note that there's also an option 'Jar File'; I think it's more flexible than creating a runnable .jar file: add all packages and resources and a manifest, turn on the bubble machine and voila, there's your hand made .jar file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    CuppaCoffee's Avatar
    CuppaCoffee is offline Member
    Join Date
    Jan 2012
    Location
    Canada
    Posts
    80
    Rep Power
    0

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Quote Originally Posted by jim829 View Post
    Under File, go to export...
    Then choose runnable Jar file. This does work but it has limited functionality. And interrogating regular jar files and manipulating them under Eclipse is almost non-existent. One of these days I may write a plugin.

    Regards,
    Jim
    Quote Originally Posted by JosAH View Post
    Note that there's also an option 'Jar File'; I think it's more flexible than creating a runnable .jar file: add all packages and resources and a manifest, turn on the bubble machine and voila, there's your hand made .jar file.

    kind regards,

    Jos
    Yes, I've figured it out with the Runnable Jar method. Many thanks. My final question on the issue, if it can answered; Is there a way to make the file type an Application, rather than a JAR? When I right-click the file to see details, it says Type of File: Executable Jar File (.jar), while other normal applications say Application (.exe). Is there any way to make it an .exe rather than a .jar, or is that yet another limit of Java? Can I also change the icon image? The coffee cup thing seems rather bland.

  10. #10
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    I don't know those MS Windows specific things, sorry about that. I don't think it's a limitation of Java though; a .jar file isn't a binary executable file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,912
    Rep Power
    5

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    I know there are programs available to do that. I don't know the specifics but the target system will still need a JRE to run the app. I believe this topic was discussed in this forum. Try searching the posts using .exe as the keyword.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    They are called 'jar wrappers'; I don't think I've ever seen a single one that can generate an executable for all popular platforms. And yes you still need a proper runtime, the executable that you can generate using these tools is basically a more specific version of Java.exe - it binds to a pre-installed Java runtime and starts up the virtual machine. Some of them are clever enough that they can detect Java is not installed and can route the user to java.com.

    But executable jars are not a limit - they are a feature. An .exe does not work on Linux or Mac, but the executable jar does.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  13. #13
    CuppaCoffee's Avatar
    CuppaCoffee is offline Member
    Join Date
    Jan 2012
    Location
    Canada
    Posts
    80
    Rep Power
    0

    Default Re: How to Start Program with Desktop Launcher Rather than Through Java (Eclipse)?

    Quote Originally Posted by JosAH View Post
    I don't know those MS Windows specific things, sorry about that. I don't think it's a limitation of Java though; a .jar file isn't a binary executable file.

    kind regards,

    Jos
    Quote Originally Posted by jim829 View Post
    I know there are programs available to do that. I don't know the specifics but the target system will still need a JRE to run the app. I believe this topic was discussed in this forum. Try searching the posts using .exe as the keyword.

    Regards,
    Jim
    I see. I'll be sure to do that. Regardless, thanks for all the help, you guys have been really informative.

    Quote Originally Posted by gimbal2 View Post
    They are called 'jar wrappers'; I don't think I've ever seen a single one that can generate an executable for all popular platforms. And yes you still need a proper runtime, the executable that you can generate using these tools is basically a more specific version of Java.exe - it binds to a pre-installed Java runtime and starts up the virtual machine. Some of them are clever enough that they can detect Java is not installed and can route the user to java.com.

    But executable jars are not a limit - they are a feature. An .exe does not work on Linux or Mac, but the executable jar does.
    Is that so? I guess I was out of place to call it a limit. Perhaps it's just my own inexperience. When running the Jar File, things like pictures and .txt/.dat files can't be located, and are returned as 'null'...

    edit: Nevermind after the 'null' thing. Just another blonde moment, hehe.
    Last edited by CuppaCoffee; 07-23-2013 at 11:53 PM.

Similar Threads

  1. Replies: 1
    Last Post: 01-18-2011, 07:27 PM
  2. Replies: 0
    Last Post: 12-21-2010, 04:21 PM
  3. Replies: 2
    Last Post: 06-30-2010, 08:19 AM
  4. Replies: 5
    Last Post: 03-20-2009, 11:04 PM
  5. writing a program launcher (or Timer)
    By Farzaneh in forum Threads and Synchronization
    Replies: 3
    Last Post: 02-17-2009, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •