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

How do I actually run Java applications on my computer?

Options
  • 14-07-2013 12:38pm
    #1
    Closed Accounts Posts: 235 ✭✭


    Hi,

    I have been learning Java for a little while now. And there is an answer I can't seem to find in my book or anywhere on the internet.

    I have been doing some exercises like creating simple card games etc.. from the book. But if for some reason I actually wanted to take the code for my card game and put it in a 'package' (I use the word package generally here) so that I could create an icon on the desktop and click on it to run my card game how would I go about this?


Comments

  • Registered Users Posts: 1,731 ✭✭✭GreenWolfe


    You need to create a JAR file. It contains all of the resources and classes that you need to run your program.

    If you're just using a terminal, Oracle's instructions are here.

    It should be enough of a start to look up resources for your particular IDE, if you're using one.


  • Closed Accounts Posts: 1,235 ✭✭✭returnNull


    you normally have to include a manifest file with the JAR file.

    You can also get software that creates a normal windows .exe file for you so less technical people can stay away from the command line :pac: and just click on it as normal and it will install.

    I have used Jsmooth and launch4j,slightly prefer launch4j

    EDIT:heres the links for both

    http://jsmooth.sourceforge.net/index.php
    http://launch4j.sourceforge.net/


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,086 Mod ✭✭✭✭Tar.Aldarion




  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    If you had to deploy to many PCs (say for example, in a business scenario, deploying an app to all pcs in an Office) then deployment via webstart can be very useful. Once applications are installed on the clients PCs via webstart, then further updates are installed to the server and when the clients start it compare their current version to the latest version on the servers and, if needs be, downloads & deployments any updates.


  • Closed Accounts Posts: 724 ✭✭✭Flibbles


    I've found that having a goat, candles, and knowledge of the Occult will help with creating executable JAR files without using a third party tool (such as the ones recommended by returnNull).


  • Advertisement
  • Closed Accounts Posts: 235 ✭✭Username99


    Flibbles wrote: »
    I've found that having a goat, candles, and knowledge of the Occult will help with creating executable JAR files without using a third party tool (such as the ones recommended by returnNull).

    Ha, Ha, well I actually have a goat, I am sure there are some candles somewhere, if not i'll nip into Tesco so I am 2/3 of the way there as for the knowledge of the Occult I knew I was missing something.

    I am a complete noob so please excuse my ignorance but why would one prefer to create a Jar file without using a third party tool, if using a third party tool is easier?


  • Closed Accounts Posts: 724 ✭✭✭Flibbles


    Username99 wrote: »
    Ha, Ha, well I actually have a goat, I am sure there are some candles somewhere, if not i'll nip into Tesco so I am 2/3 of the way there as for the knowledge of the Occult I knew I was missing something.

    I am a complete noob so please excuse my ignorance but why would one prefer to create a Jar file without using a third party tool, if using a third party tool is easier?

    Street cred. Or an employer who says "no third party tools", an unfortunate reality. :rolleyes:


  • Closed Accounts Posts: 235 ✭✭Username99


    You need to create a JAR file. It contains all of the resources and classes that you need to run your program.

    If you're just using a terminal, Oracle's instructions are here.

    It should be enough of a start to look up resources for your particular IDE, if you're using one.

    I have been using BlueJ up until now, I have just downloaded NetBeans so that is what I will be switching too.

    To be honest I don't know what you mean by terminal:eek:


  • Closed Accounts Posts: 235 ✭✭Username99


    croo wrote: »
    If you had to deploy to many PCs (say for example, in a business scenario, deploying an app to all pcs in an Office) then deployment via webstart can be very useful. Once applications are installed on the clients PCs via webstart, then further updates are installed to the server and when the clients start it compare their current version to the latest version on the servers and, if needs be, downloads & deployments any updates.

    Thanks for the help, but that is honestly way over my head.


  • Closed Accounts Posts: 235 ✭✭Username99


    Flibbles wrote: »
    Street cred. Or an employer who says "no third party tools", an unfortunate reality. :rolleyes:

    Ha, Ha, thanks. I think my street cred is at an all time low after starting this thread :pac:


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,086 Mod ✭✭✭✭Tar.Aldarion


    Username99 wrote: »
    I have been using BlueJ up until now, I have just downloaded NetBeans so that is what I will be switching too.

    To be honest I don't know what you mean by terminal:eek:

    I'm going to go ahead ans assume you are using windows (and are french)

    This is the terminal:

    terminal-windows.jpg


  • Closed Accounts Posts: 235 ✭✭Username99


    I'm going to go ahead ans assume you are using windows (and are french)

    This is the terminal:

    terminal-windows.jpg

    Oh right, in France we call that the command prompt, by France I mean in the land of hopeless programmers where I am destined to languish for all eternity :pac:

    Thanks


  • Registered Users Posts: 3,860 ✭✭✭ozmo


    Username99 wrote: »
    Oh right, in France we call that the command prompt, by France I mean in the land of hopeless programmers where I am destined to languish for all eternity :pac:

    Thanks

    You will need Java installed as well on the destination pc -
    And if they dont have it - there is no nice warning - just nothing happens.

    I'd recommend a third party "launcher" program - like for example similar to what minecraft uses (thats written in java) - an exe that will check if the correct java is installed and direct you to the oracle page to download it if not present or wrong version....then run the java code.


    Either that - or ditching Java like almost everyone else and writing in DotNet - or any other language - whatever about java serverside or for mobiles - but java on the windows desktop is just nasty in so many ways... (imo)

    “Roll it back”



  • Registered Users Posts: 3,860 ✭✭✭ozmo


    Oh - might have misread your post - thought you wanted to package it for running on another pc.

    If you just want to run it via an icon on desktop-

    Just create a windows shortcut on the desktop and for the application (right click on desktop and create shortcut)
    Make it like the following:

    262776.png

    The "myapp" is the name of your class file - note: no .class extension and no full path

    The "start in" is the path where your class file is

    Both are important.

    then choose an icon.


    hope it helps.

    (note: you can use "%windir%\system32\java.exe myapp" without quotes if you prefer)

    “Roll it back”



  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    Username99 wrote: »
    Thanks for the help, but that is honestly way over my head.
    Sorry I missed the bit that you were just learning java!

    I mostly using linux myself not windows but on the open source business app I'm involved with we used Launch4j to build the executable on windows.

    It's fairly straight forward, you just pass in an XML file telling launch4j what jars files to include and which class is the main class that will launch off your application, and of course, the name of the output launcher file to be created.

    **EDIT: I just noticed that returnNull already mentioned Launch4j at the start!


Advertisement