Parameter Übergabe String[]

ProfSamba

Grünschnabel
Hi, habe eine Klasse (ConcurrentUsers) (in einem Jar) die Api sagt folgendes:

static void main(String[] arg)
The main entry point of the command line program.

ist nicht viel, aber in einer externen Hilfe wird angegeben, dass mann das eigentliche Command Line Tool mit folgenden parametern aufrufen kann... blabla..
PHP:
        String[] args = null;                                       //die Parameter die ich dann übergeben will
        args[0] = "-V";
        args[1] = "194.195.243.22:1790";

        ConcurrentUsers.main(args);                        //Das ist die Classe in dem JAR

versteht jemand wie ich es vor habe? ist es überhaupt möglich diese Klasse in eine Applikation einzubinden?beim Compilieren gibt es keine Fehler, beim Ausführen jedoch dann eine NullPointerException

Hoffe mir kann geholfen werden...
danke
Matze
 
Servus!

Code:
public class HalloTest{
    public HalloTest(){}
    public static void main(String[] args){
        System.out.println("Hallo Welt!");
        try{
            Class.forName("ForeignMain").newInstance();
        }catch(Exception e){e.printStackTrace();}
        
        ForeignMain.main(new String[]{"Hallo"});
    }
}

--------------------------

/*
 * ForeignMain.java
 *
 * Created on 24. Oktober 2003, 18:26
 */

/**
 *
 * @author  Administrator
 */
public class ForeignMain {
    
    static {
        System.out.println("Klasse ForeignMain wird geladen...");
    }
    
    /** Creates a new instance of ForeignMain */
    public ForeignMain() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println("ForeignMain ..." + args[0]);
    }
    
}

Edit Manifest.mf

Inhalt --->
Main-Class: HalloTest

jar -cvfm Test.jar Manifest.mf HalloTest.class ForeignMain.class

....

dann noch:

java -jar Test.jar

Das funktioniert bei mir ...

Gruß Tom
 

Neue Beiträge

Zurück