From 739d520c9fe985813f85d76b591daf495f702464 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 14 Feb 2026 17:09:23 +0530 Subject: Added a sample project that shows how to create and use jar files. --- java/07-simple-objects-better-use-jar/myapp/.gitignore | 1 + .../myapp/AccountApp.java | 16 ++++++++++++++++ java/07-simple-objects-better-use-jar/myapp/README | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 java/07-simple-objects-better-use-jar/myapp/.gitignore create mode 100644 java/07-simple-objects-better-use-jar/myapp/AccountApp.java create mode 100644 java/07-simple-objects-better-use-jar/myapp/README (limited to 'java/07-simple-objects-better-use-jar/myapp') diff --git a/java/07-simple-objects-better-use-jar/myapp/.gitignore b/java/07-simple-objects-better-use-jar/myapp/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/java/07-simple-objects-better-use-jar/myapp/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/java/07-simple-objects-better-use-jar/myapp/AccountApp.java b/java/07-simple-objects-better-use-jar/myapp/AccountApp.java new file mode 100644 index 0000000..3399770 --- /dev/null +++ b/java/07-simple-objects-better-use-jar/myapp/AccountApp.java @@ -0,0 +1,16 @@ +public class AccountApp { + + /** + * @param args + */ + public static void main(String[] args) { + AccountManager accountManager = new AccountManager(); + + System.out.println(accountManager.getBalance(2)); + + accountManager.deposit(2, 2.0); + + System.out.println(accountManager.getBalance(2)); + } + +} diff --git a/java/07-simple-objects-better-use-jar/myapp/README b/java/07-simple-objects-better-use-jar/myapp/README new file mode 100644 index 0000000..80ed401 --- /dev/null +++ b/java/07-simple-objects-better-use-jar/myapp/README @@ -0,0 +1,10 @@ +# 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 -- cgit v1.2.3