Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Java code on the command line in Mac OS X

Tags:

java

macos

Really basic question I'm sure for some of you Java heads out there.

I have a list of java files and jars that are required.

On windows to build I have this batch file

javac -cp .;opencsv-1.8.jar;mysql-connector.jar -source 1.4 -target 1.4 *.java
jar cvf cup.jar *.class
del *.class

If I want to do the same thing on mac how would a write a shell script to do the same?

like image 669
Derek Organ Avatar asked Aug 05 '26 16:08

Derek Organ


1 Answers

Basically the same thing, except

  1. The path separator is ':' instead of ';'
  2. I believe the command to delete is called 'rm'

Also, I'd put a shabang at the start.

So:

#!/bin/sh
javac -cp .:opencsv-1.8.jar:mysql-connector.jar -source 1.4 -target 1.4 *.java
jar cvf cup.jar *.class
rm *.class
like image 184
Michael Myers Avatar answered Aug 08 '26 10:08

Michael Myers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!