\---packdemo classpath dir | \----model package | \----test package
\---packdemo classpath dir | \----model Thing.java | \----test ThingTest.java
//Thing.java package model; public class Thing { public String whoAreYou() { return "I am Thing"; } }
ThingTest.java package test; public class ThingTest {
ThingTest.java package test; import model.Thing; public class ThingTest {
echo off REM compile.bat REM We can run this script from any dir REM because classpath will tell Java where to look set Root=C:\Work\Courses\packdemo javac -classpath %Root% %Root%\model\Thing.java javac -classpath %Root% %Root%\test\ThingTest.java pause
echo off REM run.bat REM We can run this script from any dir REM because classpath will tell Java where to look set Root=C:\Work\Courses\packdemo java -classpath %Root% test.ThingTest pause
echo off rem compileFromProjectDir.bat REM Assuming we are in root dir (where packages live) REM "." means current dir javac -classpath "." model\Thing.java javac -classpath "." test\ThingTest.java pause
echo off REM runFromProjectDir.bat REM Assuming we are in root dir (where packages live) REM "." means current dir java -classpath "." test.ThingTest pause
\---packdemo classpath dir | \----model Thing.java | \----test ThingTest.java