summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-02-16 07:28:53 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-02-16 07:28:53 +0530
commitfb41c4222778536d53f01bba9c9ff66eb06686a9 (patch)
tree15924bd250f05aa19a15f918ab5587f4fc1fbf34
parent1f8175bda9a99cf4c2d2e70004941c45e942024f (diff)
Added more details to create Windows batch files
-rw-r--r--java/07-simple-objects-better-use-jar/README50
-rw-r--r--java/07-simple-objects-better-use-jar/myaccountslib/README11
-rwxr-xr-xjava/07-simple-objects-better-use-jar/myaccountslib/run.sh18
-rw-r--r--java/07-simple-objects-better-use-jar/myapp/README10
-rwxr-xr-xjava/07-simple-objects-better-use-jar/myapp/run.sh15
5 files changed, 83 insertions, 21 deletions
diff --git a/java/07-simple-objects-better-use-jar/README b/java/07-simple-objects-better-use-jar/README
new file mode 100644
index 0000000..f167665
--- /dev/null
+++ b/java/07-simple-objects-better-use-jar/README
@@ -0,0 +1,50 @@
+Commands to be executed are put in run.sh files in the two directories.
+
+On Linux, you can execute them as follows:
+
+ cd myaccountslib
+ ./run.sh
+
+ cd ../myapp
+ ./run.sh
+
+#### Exercise for Windows users ####
+
+Jump to myaccountslib directory.
+
+Copy the content of run.sh and save in a file called run.bat.
+
+Modify run.bat with commands that can be executed in a Command Prompt to
+accomplish the same operations found in run.sh. Look at the NOTES section below
+for assistance.
+
+Run the batch file (run.bat) as follows:
+
+ .\run.bat
+
+Do the same for the run.sh file found inside the myapp directory.
+
+So on Windows, the commands may be executed as follows:
+
+ cd myaccountslib
+ .\run.bat
+
+ cd ..\myapp
+ .\run.bat
+
+
+NOTES:
+
+While coming up with run.bat files on Windows,
+
+ 1. The initial '#!/bin/bash' line is not needed.
+
+ 2. Instead of '#' character to comment lines of text, use '@REM' without quotes.
+
+ 3. To delete a directory with content inside, you can use the rmdir command like this:
+ rmdir /s /q "Path\to\directory"
+
+ 4. Windows uses '\' as the directory seperator instead of '/' in Linux.
+
+ 5. Windows uses ';' as the path seperator instead of ':' in Linux.
+
diff --git a/java/07-simple-objects-better-use-jar/myaccountslib/README b/java/07-simple-objects-better-use-jar/myaccountslib/README
deleted file mode 100644
index 72a980e..0000000
--- a/java/07-simple-objects-better-use-jar/myaccountslib/README
+++ /dev/null
@@ -1,11 +0,0 @@
-# NOTE:
-# On Windows,
-# 1. Use \ as the directory seperator.
-
-# Compile:
-mkdir bin
-javac --source-path src/ -d bin/ src/*.java
-
-# Build jar file:
-mkdir dist
-jar cf dist/myaccountslib.jar -C bin .
diff --git a/java/07-simple-objects-better-use-jar/myaccountslib/run.sh b/java/07-simple-objects-better-use-jar/myaccountslib/run.sh
new file mode 100755
index 0000000..0395e57
--- /dev/null
+++ b/java/07-simple-objects-better-use-jar/myaccountslib/run.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# This is a Linux executable bash script.
+
+# Delete directories named bin and dist
+rm -rf bin dist
+
+# Create bin directory
+mkdir bin
+
+# Compile .java files inside src directory into bin directory
+javac -d bin src/*.java
+
+# Create dist directory
+mkdir dist
+
+# Create a jar file inside dist directory. Use all the files inside bin directory.
+jar cf dist/myaccountslib.jar -C bin .
diff --git a/java/07-simple-objects-better-use-jar/myapp/README b/java/07-simple-objects-better-use-jar/myapp/README
deleted file mode 100644
index 80ed401..0000000
--- a/java/07-simple-objects-better-use-jar/myapp/README
+++ /dev/null
@@ -1,10 +0,0 @@
-# NOTE:
-# On Windows,
-# 1. Instead of using ':' as the classpath seperator, use ';'.
-# 2. Use \ as the directory seperator.
-
-# Compile
-javac -cp ../myaccountslib/dist/myaccountslib.jar:. AccountApp.java
-
-# Run
-java -cp ../myaccountslib/dist/myaccountslib.jar:. AccountApp
diff --git a/java/07-simple-objects-better-use-jar/myapp/run.sh b/java/07-simple-objects-better-use-jar/myapp/run.sh
new file mode 100755
index 0000000..a6fe2ed
--- /dev/null
+++ b/java/07-simple-objects-better-use-jar/myapp/run.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# This is a Linux executable bash script.
+
+# Delete .class files
+rm *.class
+
+# Compile
+
+# Note that the classpath specified includes a jar file and the current working
+# direcoty identified by '.'.
+javac -cp ../myaccountslib/dist/myaccountslib.jar:. AccountApp.java
+
+# Run
+java -cp ../myaccountslib/dist/myaccountslib.jar:. AccountApp