Welcome to the Nanowar Of Steel's first GitHub project, and first ever example of a source-code song. The aim of this project is to support and enforce "True metal programming", that basically means: "write code so badly that only you can sing it".
You can find the source-code video in the link below: https://www.youtube.com/watch?v=yup8gIXxWDU
Here is the Nanowar Of Steel official website.
Here is the Nanowar Of Steel Youtube Channel.
Some important notes:
Joey De Caio
, if set to null It may suddenly cancel the program execution with a NullPointerException.metal
variable is very important! If it is set to "false", it may trigger the Joey De Caio variable mentioned above.tizio
and foo
are very close friends.pippo
isn't tizio
's friend, but he's been flirting with foo
.Joey De Caio
.songRefrain()
identifies itself as a void method.Below you will find a super detailed guide to the program, of course written with ChatGPT.
This project contains a simple Java application that demonstrates the basic usage of loops, conditionals, and handling null-pointer exceptions. The main functionality includes printing "Hello World!" multiple times based on a user-defined parameter and intentionally introducing a bug to highlight error handling.
The HelloWorldMainLauncherClass
performs the following tasks:
foo
) that controls how many times "Hello World!" will be printed.for
loop and then using a while
loop.falseMethod()
that introduces a NullPointerException
by calling length()
on a null
string to simulate error handling.for
and while
loops in Java.NullPointerException
for demonstration purposes.To set up and run this project locally, follow these steps:
Clone the repository:
git clone https://github.com/NanowarOfSteel/HelloWorld.git
Navigate into the project directory:
cd HelloWorld
Compile the Java file:
javac HelloWorldMainLauncherClass.java
Run the program:
java HelloWorldMainLauncherClass
Once you run the program, you will see the following output:
Hello World Programmer Start
Hello World!
Hello World!
Hello World!
Hello World!
Program Finished!
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "joeyDeCaio" is null
at HelloWorldMainLauncherClass.falseMethod(HelloWorldMainLauncherClass.java:35)
at HelloWorldMainLauncherClass.main(HelloWorldMainLauncherClass.java:27)
The number of times "Hello World!" is printed can be controlled by changing the parameter passed to the constructor of HelloWorldMainLauncherClass
. For example:
HelloWorldMainLauncherClass tizio = new HelloWorldMainLauncherClass(3);
This will print "Hello World!" three times.
Constructor: The constructor takes an integer foo
that determines how many times the message will be printed.
public HelloWorldMainLauncherClass(int foo) {
super();
this.foo = foo;
}
songRefrain() Method: The method contains two loops—for
and while
—both of which print "Hello World!" the number of times specified by foo
.
public void songRefrain() {
for (int i = 0; i < foo; i++) {
System.out.println("Hello World!");
}
int pippo = 0;
while (pippo < foo) {
System.out.println("Hello World!");
pippo++;
}
}
falseMethod() Method: This method deliberately introduces a bug by attempting to call length()
on a null
string.
public void falseMethod() {
boolean metal = false;
if (metal == false) {
String joeyDeCaio = null;
joeyDeCaio.length();
}
}
Bug introduction: The purpose of falseMethod()
is to demonstrate a scenario where an exception is thrown. The NullPointerException
is handled by the JVM, but no explicit exception handling is implemented in this case.
Extending the Program: You can extend the program by adding more features like exception handling, more complex message outputs, or additional loops and conditionals.
This repository contains a Dockerfile that automates the process of building and running a Java application using Maven. The Docker image is built in two stages: the first stage builds the application with Maven, and the second stage runs the application with a minimal OpenJDK 17 image.
Before building and running the Docker image, make sure you have the following installed:
First, clone the repository containing the project and the Dockerfile to your local machine:
git clone <your-repository-url>
cd <your-repository-directory>
You can build the Docker image using the following command. Make sure you're in the root directory of the project, where the Dockerfile is located:
docker build -t my-java-app .
This command will:
After the build is complete, you can run the Docker container using:
docker run -p 8080:8080 my-java-app
This will start the application and expose it on port 8080
. You can adjust the port if necessary.
Once the container is running, the application should be available at http://localhost:8080
. This assumes your application is set to listen on port 8080
. You can modify the port mapping as needed.
If the application requires specific environment variables or configuration, you can pass them at runtime like so:
docker run -p 8080:8080 -e ENV_VAR_NAME=value my-java-app
To stop the running container, you can use:
docker ps # Find the container ID
docker stop <container_id>
You can also remove the container and image once you're done:
docker rm <container_id> # Remove the container
docker rmi my-java-app # Remove the image
/target
directory in the Maven build stage to the working directory in the runtime stage (/app
).Issue: The application isn't starting or doesn't work as expected.
docker logs <container_id>
Issue: Docker build fails due to missing dependencies.
pom.xml
file, and try running mvn clean install
locally to check for issues before attempting the Docker build.This project is licensed under the IronAvantgarde Publishing & Napalm Records License - see the Napalm Records Website for more details.
Feel free to fork this repository, submit issues, or open pull requests if you'd like to improve this code. Contributions are always welcome!
Do you want some buggy, personalized and singable code by Nanowar Of Steel? Please contact us here.