How start my application as server from console?

67 Views Asked by At

In IntellIJ IDEA I start my Kotlin project like server. Here my run config:

enter image description here

Nice. It's start on port 3333.

I use this classes for server

import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType

OK.

But I need to start my application as server from console.

How I can do this?

I try this:

java server config.yml -jar com.myproject.jar

but I get error:

Error: Could not find or load main class server
3

There are 3 best solutions below

0
Ignatiamus On BEST ANSWER

You have to put your command line arguments after the parameters for the JVM, e.g.

java -jar com.myproject.jar server config.yml

If you need to specify a main class which is located somewhere in your Jar do the following:

java -cp com.myproject.jar com.myproject.AppStarterKt server config.yml
0
finder2 On

You may put your main class in the manifest file or add it as argument. Have a look at this post.

0
Lakshan Dissanayake On

I'm think that's because the invalid arguments you used in java server config.yml -jar com.myproject.jar

I think this might be the solution