JP Silvashy
JP Silvashy

Reputation: 48525

Linux equivalent of including the classpath during compilation

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?

Upvotes: 1

Views: 142

Answers (2)

Mad Physicist
Mad Physicist

Reputation: 114350

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

Upvotes: 1

rrobby86
rrobby86

Reputation: 1474

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

Upvotes: 1

Related Questions