Executing code modules (seperate jars) from main program (main.jar)

Hi all
Sorry if i am crossposting, but i dont think that is the case.
I have a main program ( in a jar ) and some modules to be executed and run in the main program.
Theese components are packed a module in a single jar, and all theese jars are located in the same folder as the main program.
The main classes in the module jars implement a interface known to the main tool, so that i can use them.
My problem are, how to load the modules?
I know i can use JarFile to get the manifests, and thereby get the name of the main class in each jar (they get obfuscated before launch, so no hardcoding of names).
But how do i instanciate the mainclasses in the modules from the main tool ?
hope you can help out.
-Anders

You can't. I understand the module approach as many others have similar designs. The first problem is that you need to add all the JARs to your classpath so that these JARs are known during starttime. There is no other solution to this if you don't write your own classloader that fetches classes during runtime and work peacefully with the other classloaders of the VM (it's a pain in the ass!). So, your main application needs to know the JAR files. Then it's a small step to also register the modules that your main app should know. Our approach is to have a small database table that holds the fully referenced class names of the modules that are available and can be used via Class.forName(). With this solution, we just need to stop the main app, copy the new JAR, adjust the classpath to add the new JAR, and restart the main app. After adding the new module names to the config table, the main app automatically uses them. Instead of a database table you can use e.g. a properties file.

Similar Messages

  • It is possible to programmatically disable the "Executing Code Modules in an External Instance of CVI" feature?

    It is possible to programmatically disable the "Executing Code Modules in an External Instance of CVI" feature within a CVI project?
    I know how to do it manually (Configure > Adapters... > Adapter Configuration).
    Thanks in advance,
    --M

    Yes. TestStand 2.0 added the Engine.CVIAdapter_ExecuteStepsInCVI property.

  • Path to rt.jar from C program

    How do I get path to rt.jar from a program written in C.
    Thank you

    Just like anything else you do in C. Pass in in via the command line or use a config file or use an environment variable or parse the registry (OS specific), etc.

  • Error while trying to execute a unix shell script from java program

    Hi
    I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
    The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
    try {
         File file_location = new File("/usr/bin/");
         String file_location1 = "/opt/app/Hyperion/scripts/daily";
         String a_mib_name = "test.sh";
         String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
         Runtime rtime = Runtime.getRuntime();
         Process p = rtime.exec(cmd, null, file_location);
    System.out.println( "Connected to the server1" );
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = br.readLine();
    while(line !=null)
    System.out.println(line);
    line = br.readLine();
    br.close();
    p.getErrorStream ().close ();
    p.getOutputStream().close();
    int retVal = p.waitFor();
    System.out.println("wait " + retVal);
    //session.executeCommand("ls");
    catch (IOException ex) {
    I get an error message
    Connected to the server
    java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
    ): CreateProcess error=3, The system cannot find the path specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at SftpConnect.main(SftpConnect.java:143)
    Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
    e path specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    I am sure of the file path where the bash.sh and test.sh are located.
    Am i missing something? Any help would be greatly appreciated.
    Thanks
    Senthil

    Hi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
    The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
    The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
    Mycode:
    String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);
    java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at DecryptTest.main(DecryptTest.java:18)
    Can anyone please help

  • Creating and running JARs from Java programs

    OK, I have been googling and searching, but this is something I cannot work out, so I raelly need some help.
    Basically, I am building a GUI app that would generate, compile and run java programs. And I also want to enable the users to create JARs they can later double-click if they want to run the program.
    I am using Runtime to compile programs and it works just fine. When I click on a button to create a JAR, my application creates one, but when I double-click on it, it can't find main and it exits. Now that is not so much unusual, but I am positive that my manifest file is OK, because when I run the same command from the command line, then I can click on the JAR file to run it.
    So what is the deal here? I mean, why would a JAR file created from the command line run and the one created through a GUI app using the very same command could not find main?
    Any help would be graetly appreciated.

    again, another unanswered question.
    BTW I'l keep bumping these until I get an answer that works. I have been up 3 hours now trying to get this sorted and it's something that netbeans is supposed to do on its own!?!?!?!?!
    Hello, SUN, is there anyone there???
    No, didn't think so.

  • Execute application module method automatically from uix page

    Hi,
    We are developping an application using Jheadstart 10.1.2.2 (build 32) with UIX pages as a view.
    We have build a custom method on our application module class that creates and saves in a directory a chart in function of a parameter we pass to this method.
    We would like to execute this method every time we acces a form page since this pages has to show the chart that our method creates. We would like to know if it is possible to execute this method automatically every time we acces this form page without having to press a button each time.
    Thanks in advanced.
    Xavier

    Xavier,
    I am not sure UIX works as JSPX and JHS 10.1.2 as 10.1.3, but that is what I would do if I wanted to execute a method on page load:
    1. Create a new managed bean(MyBean) in your faces-config which implements oracle.adf.controller.v2.PagePhaseListener interface
    2. Go to the pagedef file of your page, right click it in structure pane and set the controller class to 'MyBean'
    3. in MyBean and in beforePhase() method access App Module and call your function [see 4]. I quote this from ADF Dev.Guide 10.1.3 for how you can get App Module and call your function on it:
    // 1. Access the FacesContext
    FacesContext fc = FacesContext.getCurrentInstance();
    // 2. Create value binding for the #{data} EL expression
    ValueBinding vb = fc.getApplication().createValueBinding("#{data}");
    // 3. Evaluate the value binding, casting the result to BindingContext
    BindingContext bc = (BindingContext)vb.getValue(fc);
    // 4. Find the data control by name from the binding context
    DCDataControl dc = bc.findDataControl("SRServiceDataControl");
    // 5. Access the application module data provider
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    // 6. Cast the ApplicationModule to its client interface
    SRService service = (SRService)am;
    // 7. Call a method on the client interface
    service.doSomethingInteresting();
    4. Check the phase and call your function in beforePhase method of your MyBean (implementing PagePhaseListener)
    public void beforePhase(PagePhaseEvent event) {
    FacesPageLifecycleContext ctx =(FacesPageLifecycleContext)event.getLifecycleContext();
    if (event.getPhaseId() == MY_DESIRED_PHASE) service.doSomethingInteresting();
    Probably, there is a shortcut to all these, or an alternative approach, which I myself will be happy to know about.

  • Executing procedure at regular interval from java program

    hi,
    I want to write java program that will execute procedure at regular interval,
    please give me hint how it will happen??????

    Use THREAD and Thread.sleep

  • Compare two sequences loaded in a C# code module.

    Hi,
    Is it possible to compare two sequences loaded in a C# code module using functionality from the TestStand API?
    Best regards

    Hello,
    Here you can find a related post:
    http://forums.ni.com/ni/board/message?board.id=330&message.id=26058&requireLogin=False
    Let me know if you have further questions or if this doesn't help you.
    Kind Regards,
    Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
    CLD, CTA
    If someone helped you, let them know. Mark as solved and/or give a kudo.

  • Execute jar from my java code

    Hi,
    My CDC application run in Windows Mobile, with Creme JVM.
    I need from my java code, run other .jar. and later, finish may application atual.
    I try like this:
    Runtime.getRuntime().exec("\\Windows\\CrEme\\bin\\CrEme.exe -jar \\Windows\\sample\\cube.jar");
    System.exit(0);
    But my second jar its not started. Anybody can help me?
    Other question, If I getRuntime(), am I using the atual instance of my JVM. If I exec other JAR, and later exit() my atual, the second jar its exit too?
    I'm building a automatic upgrade module in my application. With Hessian (Web Service), I download my new jar. But, I need have other jar, start it and close my jar atual. My second jar showld be delete my atual, rename the new jar downloaded for the standard name, and later start the jar download, how new version.
    thanks,
    Fabio
    Edited by: FabioPinheiro on Mar 28, 2008 4:41 AM

    Hi all,
    The Mr. Rene (from NSIcom) answer my question
    Just
    Add flag -mi.
    (multiple instance)
    I try and work fine.
    thanks Rene..
    Fabio

  • Executing jar from java code, then kill parent java code

    Please suggest if there is any best way around on executing jar from java code then killing parent java code.
    a) I have desktop based java application say "Monitor.java" which runs every 5 minutes.
    b) How can I START external java application say "execute.jar" from Monitor.java THEN EXIT Monitor.java
    I tried various options using "ProcessBuilder" and calling bat file but I need Monitor (parent application to EXIT, immediately after calling child (execute.jar)
    Try1) ProcessBuilder builder = new ProcessBuilder("java -jar execute.jar");          
    Process process = builder.start();
    Try2) Runtime r = Runtime.getRuntime();
    Process p = null;
    p = r.exec(new String[] { "cmd", "/c", "start C:/temp/Test.bat" });

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

  • How to pass variable value into module pool scren from a report program

    Hi,
    I have created a report program with selection screen parameters. when the inputs are filled and executed it generates the purchase evaluation sequence number. i have created a screen and passed that number to display on it with print option and back option buttons as required. but variable alone is not getting passed from the program to module pool screen. buttons are working fine. value alone is not coming. can anyone please help me.
    regards,
    sudha.

    Hi ,
    you need to declare that variable param at Global.
    sample code...
    report xyz....
    data: g_no type ekko-ebeln.
    start-of-selection...
    g_no = '12345'.
    call screen 0100.

  • Executing ANT task from java program

    hi i would like to execute an build.xml task from a java program, and i would like to catch potential errors, thanks for you help,
    i found Launcher class, but i have the following errors :
    Buildfile: build.xml does not exist!
    Build failed
    here is the code
    String argsLauncher[]= {"D:/temp/build.xml"};
    Launcher.main(argsLauncher);
    ....

    > i would like to execute an ant task from, a java program.
    http://ant.apache.org/manual/antexternal.html
    ~

  • Is it possible to launch the SequenceAnalyzer from a C# code module in a Custom TestStand Editor

    The Sequence Analyzer is not available in the Custom TestStand Editor Mode GUI.
    Is it possible to add the Sequence Analyzer to a menu in the custom TestStand Editor?
    Is it possible to launch the sequence analyzer from a C# code module, this method is then called from a sequence call back.
    Best regards
    Patrick

    From the TS Help:
    TestStand Sequence Analyzer Application
    Select Start»All Programs»National Instruments»TestStand»Tools»TestStand Analyzer or run <TestStand>\Bin\AnalyzerApp.exe to launch the stand-alone TestStand Sequence Analyzer application. Use this application to analyze projects outside of the TestStand Sequence Editor.
    The sequence analyzer application window contains the following tabs:
    Files—The files and directories to analyze.
    Rules—The rules to use for analysis. Use this tab to enable, disable, and configure rules for analysis in the current project.
    Options—Contains the project options that control the analysis and determine whether the sequence editor automatically saves the current analyzer project.
    Messages—Contains the list of messages for the most recent analysis of the current project, sequence file, or workspace file. The sequence analyzer overwrites the content of the Messages tab each time you start an analysis session.
    Analysis Summary—Contains a summary of the most recent analysis of the project.
    Command-Line Usage
    You can use the following command-line syntax to open an analyzer project:
    AnalyzerApp.exe "C:\My Documents\MyProject.tsaproj"
    CTA, CLA, MTFBWY

  • Can't call or execute of different class files in a main program

    Hi, I got a main program which can call 3 different classes. The main program have an implicit-choice List as a starting menu. If one of the file is selected, the files will call out and display it. However, i managed to call the 1st 2 files, and the 3rd files can't display anything after selected.
    I enclosed my code as below:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Catalogues extends Form implements CommandListener {
         private Displayable parent;
         private Display display;
         private List Cata;
         private Boots bo;
         private Higheels hHeels;
         private Sandals sand;
         private Slippers sp;
        private Command backCommand = new Command("Back", Command.BACK, 1);
        private Command viewCommand = new Command("View", Command.SCREEN, 1);
        private String[] options = {"Boots", "High Heels","Sandals", "Slippers"};
         public Catalogues(Display d, Displayable p) {
              super("Welcome to Footwear World");
              Cata = new List("Select Option", List.IMPLICIT, options, null);
              display = d;
            parent = p;
              addCommand(backCommand);
              addCommand(viewCommand);
              setCommandListener(this);
         public void commandAction(Command c, Displayable d) {
         if(d==parent && c==List.SELECT_COMMAND){
              switch(parent.getSelectedIndex()){
                   case 0:
                           if(bo==null){
                              bo = new Boots(display,parent);
                             display.setCurrent(bo);
                              break;
                   case 1:
                           if(hHeels==null){
                              hHeels = new Higheels(display,parent);
                             display.setCurrent(hHeels);
                              break;
                   case 2:
                           if(sand==null){
                              sand = new Sandals(display,parent);
                             display.setCurrent(sand);
                              break;
                   case 3:
                           if(sp==null){
                              sp = new Slippers(display,parent);
                             display.setCurrent(sp);
                              break;
                   default:
             else if (c==backCommand) {
                       display.setCurrent(parent);
    }If the 3rd option is selected, i'll display above mentioned layout which contain a list to select too.
    After build this project on WToolkit. It shown an error message which is as below:
    Project settings saved
    Building "SelectCustest"
    C:\WTK22\apps\SelectCustest\src\Catalogues.java:29: cannot resolve symbol
    symbol : method getSelectedIndex ()
    location: class javax.microedition.lcdui.Displayable
    switch(parent.getSelectedIndex()){
    ^
    1 error
    com.sun.kvem.ktools.ExecutionException
    Build failed
    May i know what is problem am i facing now? And how to solve it.
    Thanks.

    Thanks to all for your thoughts and replies. I liked the xargs suggestion, so I tried that first. I would have (may still) try the stdin suggestion, followed by writing the grep output to a file.
    xargs does work, in a way I didn't expect it to, but that could be due to my inexperience with the workings of the shell.
    here's a line from my test script
    cat file | grep foo | xargs java com.company.test.TEchoArghere's the contents of 'file'
    123foo
    abc
    qafoozv
    qaz
    wsx
    qwefoort
    zxcfooh
    sdfghhere's the output from the test class, which just echos any arguments
    ::number of args: 4
    ::args[0] 123foo
    ::args[1] qafoozv
    ::args[2] qwefoort
    ::args[3] zxcfoohso xargs appends all the values from grep into an argument list and call the java class once.
    when I took xargs out of the script, nothing was passed to the class:
    ::number of args: 0this was really interesting and something to keep in my back pocket for future use.
    Thanks again to all.
    Tom

  • Execute code from a text file ...

    Hello ,  Would like to know whether it is possible to have my ABAP code in a text file in desktop and then execute the code by reading it into an ITAB in another ABAP program .
    Note : Pl. dont suggest how to upload and create a new program . I dont want to create a new program after uploading into ITAB using INSERT or function modules . I want to execute the code as part of the uploading program only . So that once the execution is complete the uploaded code will not be available in the SAP system.
    Thanks in advance ,
    Jee.R

    >
    jeeva R wrote:
    > Note : Pl. dont suggest how to upload and create a new program . I dont want to create a new program after uploading into ITAB using INSERT or function modules . I want to execute the code as part of the uploading program only . So that once the execution is complete the uploaded code will not be available in the SAP system.
    Oh dear.  The only solution to your requirement is, sadly, to upload and create a new program, and then one further step.  There is no other way.  So it looks like you'll have to do without.
    matt

Maybe you are looking for

  • Hi..............I Stuk up with a problem in JTree Please, help me any one..

    Hi, I created a JTree where the DefaultMutableTreeNode is created at run time and for this node, the leaf items are added dynamically.....Now my problem is, I should get a popup menu when i click on the treenode particularly----- * Node1 -------Node1

  • Powerbook G4 + Belkin F5D7010 card

    I'm having problems with a Powerbook G4 500 MHz in combination with a Belkin F5D7010 pcmcia card. When I insert the card, the system hangs. I cant' move the mouse, can't press any keys. When I remove the card after the hang, the system works back. Th

  • Write inputStream to file

    Hi, who could give me a short sample code how to write an inputStream or a Reader to a file. Thanks for your help Bye

  • Mouse navigations problem with Sun Java 1.5.0_*

    Hello gurus, We need to move from JInitiator to Sun Java Plugin; according to the Forms10g Client Platform Support (http://www.oracle.com/technology/products/forms/htdocs/10gR2/clientsod_forms10gR2.html) one of the certified version for Forms 10.1.2.

  • Updating Photoshop CS4 11.0 to 11.0.2 fails

    Photoshop 11.0 on Mac OS X 10.7.3 After reinstalling Photoshop on my new iMac I'm unable to run the 11.0.2 upgrade installer. It tells me that 11.0.2 is "already installed". The "About" box in Photoshop shows the version as 11.0. Any ideas?