Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quarkus with custom main method

Tags:

quarkus

Is it possible to provide a custom main(String[] args) method for a Quarkus application? Or is there any other way to access the command line arguments?

The use case would be to build a native image to be used as a command line tool.

like image 393
Harald Wellmann Avatar asked Dec 14 '22 12:12

Harald Wellmann


2 Answers

This is now officially supported :) https://quarkus.io/guides/lifecycle

import io.quarkus.runtime.annotations.QuarkusMain;
import io.quarkus.runtime.Quarkus;

@QuarkusMain  
public class Main {

    public static void main(String ... args) {
        System.out.println("Running main method");
        Quarkus.run(args); 
    }
}
like image 173
Max Avatar answered Jan 11 '23 14:01

Max


Currently Quarkus doesn't support this use case, however it is definitely on the roadmap, see: https://github.com/quarkusio/quarkus/issues/284

Update: see https://stackoverflow.com/a/61665893/2504224 for the supported way of doing this

like image 34
geoand Avatar answered Jan 11 '23 15:01

geoand