This is designed to be a fairly intuitive example usage of the Factory pattern, using hopefully what is a familiar concept to many: Minecraft mobs.
The goal here isn't to have code that actually does anything functionally. Just to show an example of how the Factory pattern can be applied.
Well, you need Java.
brew install openjdk@21This gets OpenJDK Java21 and installs it.
You can check that you're running Java21 by running:
java --version;A Mac may already have a version of Java installed in /usr/bin/java. You'll be able to tell by running:
which java;If that outputs /opt/homebrew/opt/openjdk@21/bin then you're golden. If not, you may need to play a little in ~/.zshrc.
Appending to your $path array should work:
path+=("/opt/homebrew/opt/openjdk@21/bin");If that doesn't, you can ensure that it's prepended before the standard Mac installed version:
path=("$(brew --prefix openjdk@21)/bin" $path)I've also used Maven, as that's a fairly standard choice.
brew install mvn;Check that's okay by running:
mvn --version;I then ran the following Maven command to initialise the repo:
mvn archetype:generate -DgroupId=com.example \
-DartifactId=console-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=falseNavigate into the app:
cd console-appand then run:
mvn packagejava -cp target/console-app-1.0-SNAPSHOT.jar com.example.Appmvn testor for a specific test:
mvn -Dtest=AppTest test- Mockito (for testing)
- Guice (for dependency injection)