View on GitHub

projectEulerJava

Project Euler Java Solutions

projectEulerJava

Back to james-flynn-io.github.io

CircleCI codebeat badge

What is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

https://projecteuler.net/about

The purpose of this repository is to share solutions to the problems, and to help each other improve as programmers by sharing solutions and suggesting ways to improve the code.

Feel free to contribute!

Installing Java

java -version

You should see output stating the Java version installed. If you see an error, check that the JDK installed correctly and that the Java path was added to the environment variables correctly.

cd C:\repos\projectEulerJava\

Compiling the Java Application

In order to run the Java source code files on your machine (the *.java files in the repository), we need to convert it from the human-readable text to the language which the Java Virtual Machine (JVM) understands, which is bytecode. This is known as compilation, and results in a *.class file being outputted with the same name as the .java file that was inputted.

javac p1MultiplesOf3And5/Problem1.java

This will compile the application for the Java Virtual Machine, and create the file Problem1.class

Run the Java Application

java p1MultiplesOf3And5.Problem1

You may notice that we need to add the package name in front of the class name when executing, p1MultiplesOf3And5.Problem1. Think of this as like adding the full mailing address of the class, so that the JVM can find it easily.

This command will cause the JVM to interpret the bytecode within the *.class file into commands which are understood by your OS and version of Java, and then run the program.

Have Fun!