If your Main class is in a package called FileManagement, then try:

java -cp . FileManagement.Main

in the parent folder of the FileManagement folder.

If your Main class is not in a package (the default package) then cd to the FileManagement folder and try:

java -cp . Main

More info about the CLASSPATH and how the JRE find classes:

  • How Classes are Found
  • Setting the class path (Solaris/Linux)
  • http://en.wikipedia.org/wiki/Classpath_(Java)
Answer from Bart Kiers on Stack Overflow
๐ŸŒ
It's FOSS
itsfoss.com โ€บ run-java-program-ubuntu
How to Run Java Programs in Ubuntu
January 11, 2023 - Installing JDK that also contains the Java compiler ยท The above command should work for other Debian and Ubuntu based distributions like Linux Mint, elementary OS etc. For other distributions, use your distributionโ€™s package manager.
๐ŸŒ
Princeton CS
introcs.cs.princeton.edu โ€บ java โ€บ 15inout โ€บ linux-cmd.html
Java and the Linux Command Line
This document instructs you on how to use the Linux shell with Java. For a light-hearted essasy on the command line, you might enjoy Neal Stephenson's light-hearted essay In the Beginning was the Command Line. You will use the Java compiler javac to compile your Java programs and the Java interpreter java to run ...
๐ŸŒ
FOSS Linux
fosslinux.com โ€บ home โ€บ programming โ€บ compile and run java from the linux cli (2026 developer guide)
Compile and Run Java from the Linux CLI (2026 Developer Guide)
April 29, 2026 - fosslinux@dev:~$ javac -cp ".:external_libs/utilities.jar" Main.java ยท The -cp flag defines the classpath. The dot (.) represents the current directory, and the colon (:) separates multiple paths on Linux. Windows uses a semicolon, which is a common source of cross-platform confusion. When you execute the program, you must provide the exact same classpath to the JVM, otherwise it will throw a ClassNotFoundException at runtime.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ run-java-command-line-linux
How to Run Java from Command-line in Linux โ€“ Linux Hint
It comes with a simple syntax and ... auto garbage collection facility. To run the java program in Linux, we need to verify if Java Development Kit (JDK) is available in the system and its version....
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Run Java Program in Terminal Ubuntu Linux - YouTube
In this video I am going to show you How to install Java JDK 10 on Ubuntu Linux ( with JAVA_HOME ). also we will see Steps for compiling and running a Java p...
Published ย  February 25, 2021
Find elsewhere
๐ŸŒ
Dracula Servers
draculaservers.com โ€บ home โ€บ how to run java programs in linux terminal?
How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials
June 30, 2024 - Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.
๐ŸŒ
Oracle
java.com โ€บ en โ€บ download โ€บ help โ€บ linux_install.html
How do I download and install 32-bit Java for Linux?
Unpack the tarball and install Java tar zxvf jre-8u73-linux-i586.tar.gz The Java files are installed in a directory called jre1.8.0_73 in the current directory. In this example, it is installed in the /usr/java/jre1.8.0_73 directory. Delete the .tar.gz file if you want to save disk space. Become root by running su and entering the super-user password.
๐ŸŒ
Opensource.com
opensource.com โ€บ article โ€บ 19 โ€บ 11 โ€บ install-java-linux
How to install Java on Linux | Opensource.com
Some distributions use the keyword latest to indicate the most recent version, which is usually what you need to run whatever application you're trying to run. Depending on what package manager you use, you might even consider using grep to filter the search results to include only the latest versions. For example, on Fedora: $ sudo dnf search openjdk | \ grep latest | cut -f1 -d':' java-latest-openjdk-demo.x86_64 java-openjdk.i686 java-openjdk.x86_64 java-latest-openjdk-jmods.x86_64 java-latest-openjdk-src.x86_64 java-latest-openjdk.x86_64 [...]
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-execute-and-run-java-code
How to Execute and Run Java Code from the Terminal
March 10, 2022 - For example, as I want to compile my Main.java, I will use the command javac Main.java. The c in javac indicates compile. If the compilation process is successful, then we will not get any errors. This will create the class file we need under the same directory. Keep in mind that we run the class file, not the .java file.
๐ŸŒ
Princeton CS
introcs.cs.princeton.edu โ€บ java โ€บ linux
Hello World in Java on Linux
August 14, 2019 - Any version of Java 8 (either Oracle or OpenJDK) or later should work fine. I had to manually enter the location of tools.jar in DrJava, but it doesn't seem to have any effect. Any suggestions? This setting doesn't take effect until you restart DrJava. Can I use a different IDE? Yes, feel free to use another IDE (such as Eclipse) but you will have to configure the IDE properties yourself (such as the classpath). How do I determine which shell I'm running?
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ administration โ€บ service management โ€บ run a java application as a service on linux
Run a Java Application as a Service on Linux | Baeldung on Linux
March 18, 2024 - Next, we notice the system reports our service running but disabled. Disabled services will not start automatically when the system boots. Of course, we can configure it to start up automatically along with the system. This is where we use another systemctl command โ€” enable: sudo systemctl enable javasimple.service Created symlink from /etc/systemd/system/multi-user.target.wants/javasimple.service to /etc/systemd/system/javasimple.service
๐ŸŒ
VITUX
vitux.com โ€บ your-first-java-program-in-the-ubuntu-terminal
Your First Java Program in the Ubuntu Terminal โ€“ VITUX
In this article, you have learned to install both the Java Runtime Environment and the Java Development Kit used to compile and run your java programs. We also wrote a simple Hello World program in Java and ran to see if you and your system are ready to move to the more complex world of Java Programming. Vitux.com is a Linux compendium with lots of unique and up to date tutorials.
๐ŸŒ
Its Linux FOSS
itslinuxfoss.com โ€บ run-java-command-line-linux
ItsLinuxFOSS - Tutorials on Linux, Programming & Technology
To install NVM, first install the curl command. After that, you can install the NVM using the curl command. This will download and install the NVM script to run.
๐ŸŒ
Medium
medium.com โ€บ @ameyadhamnaskar โ€บ running-java-application-as-a-service-on-centos-599609d0c641
Running Java application as Linux service with systemd | by Ameya Dhamnaskar | Medium
January 24, 2019 - I assume you have your java code with all its dependencies in a jar file.This means you should right now be able to run your code using: (sudo) java -jar Name_Of_File.jar
๐ŸŒ
Oracle
java.com โ€บ en โ€บ download โ€บ help โ€บ linux_x64_install.html
Linux 64-bit installation instructions for Java
Use these instructions to download and install the Java Runtime Environment (JRE) for Linux x64.
๐ŸŒ
Oracle
docs.oracle.com โ€บ javase โ€บ tutorial โ€บ getStarted โ€บ cupojava โ€บ unix.html
"Hello World!" for Solaris OS, Linux, and Mac OS X (The Javaโ„ข Tutorials > Getting Started > The "Hello World!" Application)
Results of the ls command, showing the .java source file. Now are ready to compile the source file. At the prompt, type the following command and press Return. ... The compiler has generated a bytecode file, HelloWorldApp.class. At the prompt, type ls to see the new file that was generated: the following figure. Results of the ls command, showing the generated .class file. Now that you have a .class file, you can run your program.