javabashcentos

Problem compiling java on CentOS 5.6


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?


Solution

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

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