在 CentOS 5.6 上编译 java 时出现问题
对于 Windows,我只是使用批处理脚本来编译我的程序:
@echo off
title Building...
echo Building Server - please wait...
echo ---------------------------------------
set javac="C:\Program Files\java\jdk1.6.0_24\bin\javac.exe"
set libs=bin;
set dirs=src\server\*.java
set dirs=%dirs% src\server\commands\*.java
set dirs=%dirs% src\server\components\*.java
set dirs=%dirs% src\server\item\*.java
set dirs=%dirs% src\server\net\*.java
set dirs=%dirs% src\server\randomevent\*.java
set dirs=%dirs% src\server\minigames\*.java
set dirs=%dirs% src\server\minigames\trawler\*.java
set dirs=%dirs% src\server\minigames\trawler\game\*.java
set dirs=%dirs% src\server\quests\*.java
set dirs=%dirs% src\server\skills\runecrafting\*.java
set dirs=%dirs% src\server\skills\slayer\*.java
set dirs=%dirs% src\server\tasks\*.java
set dirs=%dirs% src\server\tasks\net\*.java
set dirs=%dirs% src\server\threading\*.java
%javac% -classpath %libs% %dirs% -d bin
echo ---------------------------------------
title Buld complete.
echo Build complete.
pause
一切都编译得很好。 所以我将我的项目移到我的 CentOS VPS 上并尝试使用 bash 脚本进行编译
echo Building...
echo Building Server - please wait...
echo ---------------------------------------
libs=bin
dirs=src/server/*.java
dirs=$dirs src/server/commands/*.java
dirs=$dirs src/server/components/*.java
dirs=$dirs src/server/item/*.java
dirs=$dirs src/server/net/*.java
dirs=$dirs src/server/randomevent/*.java
dirs=$dirs src/server/minigames/*.java
dirs=$dirs src/server/minigames/trawler/*.java
dirs=$dirs src/server/minigames/trawler/game/*.java
dirs=$dirs src/server/quests/*.java
dirs=$dirs src/server/skills/runecrafting/*.java
dirs=$dirs src/server/skills/slayer/*.java
dirs=$dirs src/server/tasks/*.java
dirs=$dirs src/server/tasks/net/*.java
dirs=$dirs src/server/threading/*.java
javac -classpath $libs $dirs -d bin
echo ---------------------------------------
title Buld complete.
echo Build complete.
我一定做错了什么。我收到这些错误:
: command not founde 4:
: No such file or directory/server/commands/*.java
: No such file or directory/server/components/*.java
: No such file or directory/server/item/*.java
: No such file or directoryc/server/net/*.java
: No such file or directoryc/server/randomevent/*.java
: No such file or directoryc/server/minigames/*.java
: No such file or directoryc/server/minigames/trawler/*.java
: No such file or directoryc/server/minigames/trawler/game/*.java
: No such file or directoryc/server/quests/*.java
: No such file or directoryc/server/skills/runecrafting/*.java
: No such file or directoryc/server/skills/slayer/*.java
: No such file or directoryc/server/tasks/*.java
: No such file or directoryc/server/tasks/net/*.java
: No such file or directoryc/server/threading/*.java
: command not founde 21:
javac: invalid flag: src/server/*.java
有人可以帮我找出我做错了什么吗?有语法错误吗?
For windows I just used a batch script to compile my program:
@echo off
title Building...
echo Building Server - please wait...
echo ---------------------------------------
set javac="C:\Program Files\java\jdk1.6.0_24\bin\javac.exe"
set libs=bin;
set dirs=src\server\*.java
set dirs=%dirs% src\server\commands\*.java
set dirs=%dirs% src\server\components\*.java
set dirs=%dirs% src\server\item\*.java
set dirs=%dirs% src\server\net\*.java
set dirs=%dirs% src\server\randomevent\*.java
set dirs=%dirs% src\server\minigames\*.java
set dirs=%dirs% src\server\minigames\trawler\*.java
set dirs=%dirs% src\server\minigames\trawler\game\*.java
set dirs=%dirs% src\server\quests\*.java
set dirs=%dirs% src\server\skills\runecrafting\*.java
set dirs=%dirs% src\server\skills\slayer\*.java
set dirs=%dirs% src\server\tasks\*.java
set dirs=%dirs% src\server\tasks\net\*.java
set dirs=%dirs% src\server\threading\*.java
%javac% -classpath %libs% %dirs% -d bin
echo ---------------------------------------
title Buld complete.
echo Build complete.
pause
Everything compiles fine.
So I move my project onto my CentOS VPS and try to compile with a bash script
echo Building...
echo Building Server - please wait...
echo ---------------------------------------
libs=bin
dirs=src/server/*.java
dirs=$dirs src/server/commands/*.java
dirs=$dirs src/server/components/*.java
dirs=$dirs src/server/item/*.java
dirs=$dirs src/server/net/*.java
dirs=$dirs src/server/randomevent/*.java
dirs=$dirs src/server/minigames/*.java
dirs=$dirs src/server/minigames/trawler/*.java
dirs=$dirs src/server/minigames/trawler/game/*.java
dirs=$dirs src/server/quests/*.java
dirs=$dirs src/server/skills/runecrafting/*.java
dirs=$dirs src/server/skills/slayer/*.java
dirs=$dirs src/server/tasks/*.java
dirs=$dirs src/server/tasks/net/*.java
dirs=$dirs src/server/threading/*.java
javac -classpath $libs $dirs -d bin
echo ---------------------------------------
title Buld complete.
echo Build complete.
And I must be doing something wrong. I get these errors:
: command not founde 4:
: No such file or directory/server/commands/*.java
: No such file or directory/server/components/*.java
: No such file or directory/server/item/*.java
: No such file or directoryc/server/net/*.java
: No such file or directoryc/server/randomevent/*.java
: No such file or directoryc/server/minigames/*.java
: No such file or directoryc/server/minigames/trawler/*.java
: No such file or directoryc/server/minigames/trawler/game/*.java
: No such file or directoryc/server/quests/*.java
: No such file or directoryc/server/skills/runecrafting/*.java
: No such file or directoryc/server/skills/slayer/*.java
: No such file or directoryc/server/tasks/*.java
: No such file or directoryc/server/tasks/net/*.java
: No such file or directoryc/server/threading/*.java
: command not founde 21:
javac: invalid flag: src/server/*.java
Can someone help me figure out what I'm doing wrong? Is there a syntax error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道为什么通配符没有被扩展,但是
dirs =
行不是有效的语法;您需要引用右侧。考虑到奇怪的错误消息,我怀疑是否使用bash
来执行脚本。你确定是吗?无论如何,哦。这是编译代码的疯狂方式。使用
Ant
或make
,它们会让您的生活变得更加轻松。Don't know why the wildcards aren't being expanded, but the
dirs =
lines aren't valid syntax; you need to quote the right hand side. Given the odd error messages, I'd question whetherbash
was being used to execute the script. Are you sure it is?In any case, oy. This is a crazy way to compile your code. Either use
Ant
ormake
, and they'll make your life a lot easier.您需要在所有作业的右侧加上引号,例如
<代码>
You need quotation marks around the right hand side of all of your assignments, e.g.