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

Making a java executable

  • 29-04-2007 5: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,334 ✭✭✭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