This is a simple particle simulator implemented in Java. It uses Swing for the graphical user interface and Java's built-in concurrency utilities for the simulation logic.
-
Open the
jarfile in thesrcdirectory, two windows should pop-up (canvas + inputs) -
Click on the dropdown to change input type
Single Particle,Constant Velocity + Varying Angle,Constant Start Points + Varying Angle,Constant Start Points + Varying Velocity,Add Wall- As for all types, simply input the required fields (X, Y, angle, velocity, etc.)
- Click on the
Addbutton after completing the inputs
-
Clear all of the
Particlesby clicking on theClear Particlesbutton -
Clear all of the
Wallsby clicking on theClear Wallsbutton -
Close either of the windows to stop the program
- Java Development Kit (JDK) 8 or later
- Open a terminal/command prompt.
- Navigate to the directory containing the
srcfolder. - Compile the Java files using the
javaccommand:
javac src/*.javaThis will compile all the Java files in the src directory and create corresponding .class files.
After compiling the program, you can run it using the java command. The main class of the program is ParticleSimulator.
java src/ParticleSimulatorThis will start the particle simulator. You can interact with the program using the graphical user interface.
- After compiling the program, navigate to the
srcdirectory:
cd src- Create a manifest file named
Manifest.txtwith the following content:
Main-Class: ParticleSimulator
Note the extra newline at the end of the file.
This tells the JAR file which class to run when it's executed.
- Create the JAR file using the
jarcommand:
jar cvfm ParticleSimulator.jar Manifest.txt *.classThis will create a JAR file named ParticleSimulator.jar that includes all the .class files in the current directory and uses the manifest file you created.
After creating the JAR file, you can run it using the java command:
java -jar ParticleSimulator.jarThis will start the particle simulator just like before, but now you're running it from a single JAR file instead of multiple .class files.
- Add particles with fixed velocity and angle.
- Add particles with a fixed start point and varying angle.
- Add particles with a fixed start point and varying velocity.
- Add walls for the particles to bounce off.
- Clear all particles or walls.