Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Andere Main Methode in Jar File starten?

Empfohlene Antworten

Hallo,

ich bin wieder an einem Punkt wo mich das Googlen und die Suchfunktion nicht weiter gebracht haben...

Ist es möglich über ein Parameter eine andere Main Methode in einer Jar File zu starten, als die im Manifest angegebene?

Danke & Gruß

LordK

Was soll das bringen? - Warum willst du ein Programm über zwei verschiedene Klassen starten? Oder versteh ich dich nicht richtig?

Ich weiß was du vorhast, du willst mit dem Aufruf

java [MAINCLASS] -jar test.jar 
eine andere Klasse des Archivs starten. Mir ist leider kein Weg bekannt und die Hilfe gibt auch keine Auskunft über ne Möglichkeit soweit ich das beurteilen kann:
Usage: java [-options] class [args...]

           (to execute a class)

   or  java [-options] -jar jarfile [args...]

           (to execute a jar file)


where options include:

    -client       to select the "client" VM

    -server       to select the "server" VM

    -hotspot      is a synonym for the "client" VM  [deprecated]

                  The default VM is client.


    -cp <class search path of directories and zip/jar files>

    -classpath <class search path of directories and zip/jar files>

                  A ; separated list of directories, JAR archives,

                  and ZIP archives to search for class files.

    -D<name>=<value>

                  set a system property

    -verbose[:class|gc|jni]

                  enable verbose output

    -version      print product version and exit

    -version:<value>

                  require the specified version to run

    -showversion  print product version and continue

    -jre-restrict-search | -jre-no-restrict-search

                  include/exclude user private JREs in the version search

    -? -help      print this help message

    -X            print help on non-standard options

    -ea[:<packagename>...|:<classname>]

    -enableassertions[:<packagename>...|:<classname>]

                  enable assertions

    -da[:<packagename>...|:<classname>]

    -disableassertions[:<packagename>...|:<classname>]

                  disable assertions

    -esa | -enablesystemassertions

                  enable system assertions

    -dsa | -disablesystemassertions

                  disable system assertions

C:\Dokumente und Einstellungen\Roder Markus>java -X

    -Xmixed           mixed mode execution (default)

    -Xint             interpreted mode execution only

    -Xbootclasspath:<directories and zip/jar files separated by ;>

                      set search path for bootstrap classes and resources

    -Xbootclasspath/a:<directories and zip/jar files separated by ;>

                      append to end of bootstrap class path

    -Xbootclasspath/p:<directories and zip/jar files separated by ;>

                      prepend in front of bootstrap class path

    -Xnoclassgc       disable class garbage collection

    -Xincgc           enable incremental garbage collection

    -Xloggc:<file>    log GC status to a file with time stamps

    -Xbatch           disable background compilation

    -Xms<size>        set initial Java heap size

    -Xmx<size>        set maximum Java heap size

    -Xss<size>        set java thread stack size

    -Xprof            output cpu profiling data

    -Xrunhprof[:help]|[:<option>=<value>, ...]

                      perform JVMPI heap, cpu, or monitor profiling

    -Xdebug           enable remote debugging

    -Xfuture          enable strictest checks, anticipating future default

    -Xrs              reduce use of OS signals by Java/VM (see documentation)

    -Xcheck:jni       perform additional checks for JNI functions


The -X options are non-standard and subject to change without notice.

Sorry :(

Naja ein Kollege hatte gefragt...

Wir haben mehrere kleine "batch" Programme die täglich laufen.

Und er meinte er fänds gut, wenn wir die alle in eine JAR File

packen könnten und dann über ein Parameter starten könnten.

Warum er das so viel besser findet weiß ich

auch nicht, er hatte halt mal gefragt ob das gehen würde.

Hi!

Wenn die "batches" Javaprogramme sind, dann schreib doch einfach eine eigene Klasse, die die main-Methoden der anderen Programme aufruft. Die main ist eine Methode wie jede andere auch.


public class StartAll {

    public static void main(String [] args){

        Programm1.main(new String[0]);

        Programm2.main(new String[0]);

    }

}

Grüsse TrueSun

Ihr könnt ja die Programme starten, ohne 'java -jar' zu verwenden. Nehmt halt 'java -classpath path_to_jar Programmname'

Peter

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.