Reputation: 1434
I created this batch file on Windows:
del /s *.class
javac com\company\bot\client\*.java
javac com\company\bot\server\Main.java
start cmd /k Call runServer.bat
start cmd /k Call runClient.bat
start cmd /k Call runMyClient.bat
Which does the job on Windows, now I want to execute the same batch file on a OSX terminal, but I get the following errors:
maasbommel:BotProgram pmeijer$ ./test.bat
./test.bat: line 1: del: command not found
javac: invalid flag: comcompanybotclient*.java
Usage: javac <options> <source files>
use -help for a list of possible options
javac: invalid flag: comcompanybotserverMain.java
Usage: javac <options> <source files>
use -help for a list of possible options
: command not found
./test.bat: line 5: start: command not found
./test.bat: line 6: start: command not found
./test.bat: line 7: start: command not found
Which kind of makes sense since there is no del command nor cmd in OSX.
So my question is how to convert this properly? I searched the internet for this problem but can not find anything useful. I hope someone can explain the concept to me.
Greetz,
Upvotes: 0
Views: 154
Reputation: 1434
Eventually solved this by using IntelliJ's run configurations. Thanks for the answers anyway.
Upvotes: 0
Reputation: 109547
You might use ant, which actually is a build tool like make
but cross-platform (XML). This way you have a cross-platform "batch" command processor.
Paying the overhead of needing to install ant.
An overview of available ant tasks. An ant file would look like:
<project name="MyProject" default="run" basedir=".">
<description>
simple example build file
</description>
<property name="src" location="src"/>
<property name="build" location="build"/>
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init" description="compile the source " >
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="clean" description="clean up" >
<delete dir="${build}"/>
</target>
<target name="run" depends="compile, clean" description="run all" >
<java dir="${exec.dir}" jar="${exec.dir}/dist/test.jar"
fork="true" failonerror="true" maxmemory="128m">
<arg value="-h"/>
<classpath>
<pathelement location="dist/test.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
</project>
Running by ant tasks exec or java.
Upvotes: 1