简体   繁体   English

在jar中运行服务器时服务器不工作

[英]server doesn't work when I run it in jar

I've got simple class which runs some Main class from some .jar file. 我有一个简单的类,它可以从一些.jar文件运行一些Main类。

public class Test {
public static void main(String[] args) {
    org.runner.Main.main(args);
}
}

But when I run via Eclipse or other IDE - it works fine. 但是,当我通过Eclipse或其他IDE运行时,它可以正常工作。 And in IDE console it shows 并且在IDE控制台中显示

C:\Users\Admin\Desktop\xultestapplication\Test\bin\myapp
C:\Users\Admin\Desktop\xultestapplication\Test\bin\myapp\defaults
C:\Users\Admin\Desktop\xultestapplication\Test\bin\myapp\chrome
C:\Users\Admin\Desktop\xultestapplication\Test\bin\myapp\chrome\content
C:\Users\Admin\Desktop\xultestapplication\Test\bin\myapp\defaults\preferences
server started!
org.runner.Calculator.calculator:org.runner.Calculator|calculator
Sent with code 200

where sent with code 200 means that it successfully sent response to client. 其中sent with code 200表示它已成功将响应发送给客户端。 But when I run it in cmd java -jar test.jar - it doesn't work and 但是当我在cmd java -jar test.jar运行它时-它不起作用并且

H:\disk\EXE>java -jar test.jar
H:\disk\EXE\bin\myapp
H:\disk\EXE\bin\myapp\defaults
H:\disk\EXE\bin\myapp\chrome
H:\disk\EXE\bin\myapp\chrome\content
H:\disk\EXE\bin\myapp\defaults\preferences
server started!
Sent with code 404

the result code is 404. 结果代码为404。

What is the problem? 问题是什么?

Perhaps the server is automatically run from within your Eclipse environment? 也许服务器是在您的Eclipse环境中自动运行的? If this is the case, you must of course make sure it is also run when starting your test outside Eclipse. 如果是这种情况,那么您当然必须确保在Eclipse外部启动测试时它也可以运行。

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

相关问题 当我从jar运行我的应用程序时,为什么新的File(path)不起作用? - Why does new File(path) doesn't work when I run my application from jar? 从JAR文件运行程序时,视频不起作用 - Video doesn't work when program is run from a JAR file Jar文件在Web服务器上不起作用 - Jar file doesn't work on the web server 构建jar时,.requestFocusInWindow()不起作用 - .requestFocusInWindow() doesn't work when build the jar 导出时从另一个Jar运行一个Jar不起作用 - Running a Jar from another Jar doesn't work when exported 默认的 android 工作室程序在我运行时不起作用 - the default android studio program doesn't work when i run it 当我在手机上运行应用程序时,后台不起作用 - Background doesn't work when I run the app on my phone 符号 λ 在 jar 文件中不起作用,但在 eclipse 中运行是 - symbol λ doesn´t work in jar file but in eclipse run yes InputMismatchException 在我从 cmd 运行 jar 时发生,如果从idea 运行则不会发生 - InputMismatchException happens when I ran jar from cmd and doesn't happen if run from idea 当我使用BlueJ将Java项目转换为.jar时,该项目无法正常运行,因为它直接来自BlueJ - When I convert a Java project to a .jar with BlueJ, the project doesn't work as it does straight from BlueJ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM