Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default Launch Jar from in application

    Hi, I need to launch a jar, or use classes within the jar, whichever is easier, from within an application. Is there any way to do this? Basically I have one application that is a jar, and in that I need to run an executable jar that is located somewhere on the computer. If it is easier, I need to run the main for a class within that jar. Any help would be greatly appreciated.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default

    If you want to just run the jar as an external task, use Runtime.exec. If you need access to the classes in the jar, add the jar to your classpath.

  3. #3
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default

    I dont need to access the classes, its an executable jar, so runtime.exec will run that? if so what would be the code?

  4. #4
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Do you mean to say that you have got everything bundled inside the JAR file and you need to run that?

    You can use the -jar command line option. Something like,

    Java Code:
    java -jar jar-file

    Make sure that your jar file contains the manifest file which has the application's entry point defined properly. Like,

    Java Code:
    Main-Class: classname
    where classname is the class file having the main method.

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Not able to launch J2ME application
    By vishal21 in forum CLDC and MIDP
    Replies: 2
    Last Post: 12-02-2010, 02:58 PM
  2. Not able to launch J2ME application
    By vishal21 in forum Sun Java Wireless Toolkit
    Replies: 1
    Last Post: 11-23-2010, 01:14 AM
  3. Java Application fails to launch without error
    By javaguy78 in forum AWT / Swing
    Replies: 9
    Last Post: 11-16-2010, 06:25 PM
  4. Replies: 1
    Last Post: 05-17-2010, 09:03 PM
  5. Replies: 4
    Last Post: 03-12-2010, 05:57 PM

Posting Permissions

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