简体   繁体   English

如何从控制台将我的应用程序作为服务器启动?

[英]How start my application as server from console?

In IntellIJ IDEA I start my Kotlin project like server.在 IntellIJ IDEA 中,我启动了类似服务器的 Kotlin 项目。 Here my run config:这是我的运行配置:

在此处输入图片说明

Nice.好的。 It's start on port 3333.它在端口 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

You have to put your command line arguments after the parameters for the JVM, eg您必须将命令行参数放在 JVM 参数之后,例如

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:如果您需要指定位于 Jar 中某处的主类,请执行以下操作:

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

You may put your main class in the manifest file or add it as argument.您可以将主类放在清单文件中或将其添加为参数。 Have a look at this post .看看这个帖子

I'm think that's because the invalid arguments you used in java server config.yml -jar com.myproject.jar我认为这是因为您在java server config.yml -jar com.myproject.jar使用的无效参数

I think this might be the solution我认为这可能是解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从我的Java应用程序中启动derby服务器 - How to start derby server from within my java application 从Eclipse启动应用程序时如何启动Java控制台? - How to start the java console when launching an application from Eclipse? 如何从我的 Web 应用程序中以服务器模式启动并继续运行 hsqldb? - How can I start and keep running hsqldb in server mode from within my web application? 如何从我的Java应用程序中与C控制台应用程序进行交互 - How to interact with a C console application from within my Java application 如何从我的Android应用程序中启动另一个应用程序 - how to start another application from my application in android 如何在Java中启动控制台应用程序并与之交互 - how to in java start and interact with the console application 如何在Mac上使用控制台禁止启动Java应用程序 - How to start Java application with console suppressed on Mac 控制台未加载 Spring-boot 徽标,如何在 tomcat 服务器上启动应用程序? - Spring-boot logo not loading on console, how to start application on tomcat server? 如何从我的 Java 应用程序与控制台应用程序交互? - How do I interact with a console application from my Java app? 如何在Windows上启动服务器应用程序 - How to start Server Application on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM