1

I'm following a guide that only includes compilation instructions on windows. How would one run this build.bat file on Linux?

The batch file looks like this:

@echo off
@echo Compiling...
javac -classpath ..\..\lib\OneWireAPI.jar;%classpath% -d . .\src\*.java

And when I run the javac command on Linux, it fails:

javac -classpath ../../lib/OneWireAPI.jar;%classpath% -d . ./src/ReadTemp.java

The output is:

javac: no source files

What is the correct way to do this?

JP Silvashy
  • 46,977
  • 48
  • 149
  • 227

2 Answers2

1

On Linux, you have to use : (colon) in place of ; (semicolon) as the path separator in Java options.

Also, if you have a classpath variable, in most common Linux shells it is referenced by $classpath rather than by %classpath%

javac -classpath ../../lib/OneWireAPI.jar:$classpath -d . ./src/ReadTemp.java
rrobby86
  • 1,356
  • 9
  • 14
1

You have two items that did not get translated correctly from Windows CMD to Unix:

  • Path separator ; should be :.
  • Environment variables should be changed from %classpath% to $CLASSPATH format. Note that pretty much everything is case-sensitive in Linux, including environment variable names, and the Java path is traditionally all-caps.

Try

javac -classpath ../../lib/OneWireAPI.jar:$CLASSPATH -d . ./src/ReadTemp.java
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264