2

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
Sofo Gial
  • 697
  • 1
  • 9
  • 20
Alexei
  • 14,350
  • 37
  • 121
  • 240

3 Answers3

1

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
Ignatiamus
  • 296
  • 1
  • 12
0

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

finder2
  • 842
  • 1
  • 11
  • 30
0

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

Lakshan Dissanayake
  • 521
  • 1
  • 4
  • 18