好吧,我正试图让这个 run.bat 在 CentOS 上工作,但我很难让它加载主类。在我的服务器上,它位于 server/build/net/com/Server(mainclass)
这是我的run.bat
@echo off
title SunScape World 1 - Port 43594
cd ../build
"C:\Program Files\Java\jdk1.7.0_10\bin\java.exe" net/com/Server 43594
pause
这是我在 CentOS 上使用的 .sh
cd ../build
"java" .net.com.Server 43594
pause
这是我遇到的错误:
Exception in thread "main" java.lang.NoClassDefFoundError: //pvpscape/build/net/com/Server
Caused by: java.lang.ClassNotFoundException: ..pvpscape.build.net.com.Server
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: ./pvpscape/build/net/com/Server. Program will exit.
最佳答案
喂,
不幸的是,bat 文件适用于 DOS,不能在 Linux 上运行。 Linux 的脚本语言是 bash 脚本(以前是 sh 脚本)。以下是 bash 脚本的介绍指南:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
查看您的 bat 脚本,我发现您正在尝试进入“../build”目录,然后使用 java 以参数 43594 运行“net/com/Server”,然后 hibernate 。在 linux bash 脚本中,我们将使用以下脚本完成此操作:
#!/bin/bash
cd ../build
java net/com/Server 43594
sleep 10
然后您需要使脚本可执行:
chmod 755 run.sh
最后运行这个脚本:
# ./run.sh
关于java - 我正在尝试让这个 run.bat 在 Linux CentOS 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19190699/