Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Making a java executable

  • 29-04-2007 06:57PM
    #1
    Registered Users, Registered Users 2 Posts: 427 ✭✭


    Hi
    I just tried making an executable java program which consists of 3 class files. The jar file compiles without any problems but when I double click on it I get an error:

    "Failed to load main-class manifest attribute from c/etc"

    Any idea of what I am doing wrong?

    I think it may be because my program requires a command shell in order to run?
    Is there any way to make the jar file launch a command shell?

    Thanks,
    Kev


Comments

  • Registered Users, Registered Users 2 Posts: 7 Devoy


    You need to add a manifest file to your jar. The manifest file allows you to specify various properties of the jar - one of these properties is called "main-class" and is suppose to contain the the full name of a class within the jar that implements a Main method. Google for "jar manifest" for more details.


  • Registered Users, Registered Users 2 Posts: 427 ✭✭Kevo


    Thanks, got that sorted but now my program doesn't really do anything since it doesn't launch a command shell. Is there anything that I can add to the jar file to launch a command shell?


  • Registered Users, Registered Users 2 Posts: 6,344 ✭✭✭OfflerCrocGod


    Kevo wrote:
    Thanks, got that sorted but now my program doesn't really do anything since it doesn't launch a command shell. Is there anything that I can add to the jar file to launch a command shell?
    Print something out but that will just flash the shell up for 1 sec so you need to print out "Press OK" and add a read statement to stop it from disappearing.


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


    I just create a batch file that runs "start javaw ....."

    After that I compile the batch file with Batch file Compiler.
    http://www.abyssmedia.com/quickbfc/

    I have the jars in a subdirectory so anyone casually looking at it thinks its just an EXE.


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


    Kevo wrote:
    Thanks, got that sorted but now my program doesn't really do anything since it doesn't launch a command shell. Is there anything that I can add to the jar file to launch a command shell?


    String[] cmdLine = {"cmd", "/K", "start"};
    Process proc = Runtime.getRuntime().exec(cmdLine);


  • Advertisement
Advertisement