0

I built a maven application that I am going to deploy as a Jar file. I had it running locally during testing with "mvn jetty:run"

Building the Jar file meant I needed a main() method to reference as an entry point, so I created one but do not know what to put in it to get the Jar to run; it just finishes with exit code 0.

So what can I put in my main method that will make the executable run my code similar to how it was built with "mvn jetty:run" ?

Below is a snapshot of my MainView class.

@SuppressWarnings("serial")
@Route(value = "")
@PWA(name = "Project Base for Vaadin Flow", shortName = "Project Base")
@Theme(value = Lumo.class, variant = Lumo.DARK)

public class MainView extends SplitLayout{  

    public MainView() {
        MainLayout fillview = new MainLayout();

        setOrientation(Orientation.VERTICAL);
        setSplitterPosition(0);

//      addThemeVariants(SplitLayoutVariant.LUMO_SMALL);

        addToPrimary(fillview.primaryLayout());        
        addToSecondary(fillview.secondaryLayout());
    }

    public static void main(String args[]){
        MainView build = new MainView();
        build;
    }

}

I did not have a main() method before the Jar creation, it would simply run MainView.

I know syntactically calling "build;" doesn't work but it shows what I am trying to do.

2EricH
  • 42
  • 8

1 Answers1

0

The Vaadin Maven archetype allows packaging the app as war file using:

mvn package -Pproduction-mode

which you can use to deploy the app in an application server, see Standalone Jetty / WAR.

If you really need to create an executable jar, you can use an embedded application server, see Embedded Jetty / Programmatically. Note that this only should be done during development. Further information about creating the jar file can be found in this question.

user7217806
  • 2,014
  • 2
  • 10
  • 12
  • 1
    Thanks for the reply, I do not think that a jar will work for me in this case. This was a helpful answer - although running this did break my deploy to heroku, so if anyone else has their app deployed keep in mind that the command above may cause problems. – 2EricH Sep 03 '19 at 20:50