在 CentOS 5.6 上编译 java 时出现问题

发布于 2024-11-08 21:53:44 字数 2885 浏览 3 评论 0原文

对于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆离笙 2024-11-15 21:53:44

不知道为什么通配符没有被扩展,但是 dirs = 行不是有效的语法;您需要引用右侧。考虑到奇怪的错误消息,我怀疑是否使用 bash 来执行脚本。你确定是吗?

无论如何,哦。这是编译代码的疯狂方式。使用 Antmake,它们会让您的生活变得更加轻松。

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 whether bash 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 or make, and they'll make your life a lot easier.

笑饮青盏花 2024-11-15 21:53:44

您需要在所有作业的右侧加上引号,例如
<代码>

dirs="$dirs src/server/commands/*.java"

You need quotation marks around the right hand side of all of your assignments, e.g.

dirs="$dirs src/server/commands/*.java"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文