Execute jar in program code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cyrus Lan

    Execute jar in program code

    I have a jar file, without source code, say abc.jar.
    I have set it in the CLASSPATH
    The main execute class in abc.jar is a.class.
    In the command prompt, I can execute the program by
    issuing "java a < someIOfile"

    But I would be like to embed it in my program.
    Can I create a "dynamic" instance from it?
  • Brad BARCLAY

    #2
    Re: Execute jar in program code

    Cyrus Lan wrote:[color=blue]
    > I have a jar file, without source code, say abc.jar.
    > I have set it in the CLASSPATH
    > The main execute class in abc.jar is a.class.
    > In the command prompt, I can execute the program by
    > issuing "java a < someIOfile"
    >
    > But I would be like to embed it in my program.
    > Can I create a "dynamic" instance from it?[/color]

    Sure. Just call "a.main(params) ". It's a static method no different
    from any other Java method, so you can call it as you desire from within
    any Java code.

    Brad BARCLAY

    --
    =-=-=-=-=-=-=-=-=
    From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
    The jSyncManager Project: http://www.jsyncmanager.org
    

    Comment

    Working...