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
๐ŸŒ
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.
๐ŸŒ
It's FOSS
itsfoss.com โ€บ run-java-program-ubuntu
How to Run Java Programs in Ubuntu
January 11, 2023 - You can use Nano editor in terminal or Gedit graphical text editor for writing your Java programs. ... If there is no error, the above command produces no output. When you compile the Java program, it generates a .class file with the class name you used in your program. You have to run this class file.
๐ŸŒ
LinuxForDevices
linuxfordevices.com โ€บ home โ€บ how to run a command-line java program on linux?
How to Run a Command-Line Java Program on Linux? - LinuxForDevices
July 19, 2021 - To install Java Runtime Environment on Ubuntu/Debian based systems: ... The output similar to shown above tells us about a functional Java Runtime Environment available on the system. Follow the steps listed below to get the bytecode from the source file, and to run the Java program. You can use any text editor (like nano, vim, etc.) to write a Java program and then save it as a .java file.
๐ŸŒ
FOSS Linux
fosslinux.com โ€บ home โ€บ programming โ€บ compile and run java from the linux cli (2026 developer guide)
How to Compile and Run Java from Command-line in Linux
April 29, 2026 - Suppose you have an older legacy application that absolutely requires Java 11 to run. You can install Java 11 alongside your existing Java 21 environment: ... fosslinux@dev:~$ sdk use java 11.0.22-tem Using java version 11.0.22-tem in this shell. fosslinux@dev:~$ java -version openjdk version "11.0.22" 2024-01-16 ยท When you close the terminal, your system reverts to your default version.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-execute-and-run-java-code
How to Execute and Run Java Code from the Terminal
March 10, 2022 - So if we simply copy the directory and add the .class file name without the extension ( .class ) later with a period ( . ), then it satisfies the condition for executing any Java code that has packages declared in the source code. The same process is also applicable for the other operating systems as well. I am providing screenshots from a Linux OS here: Running Java codes having packages within a Linux Machine ยท Great job! ๐Ÿ‘ You can now run any Java code/programs directly using a terminal.
๐ŸŒ
Princeton CS
introcs.cs.princeton.edu โ€บ java โ€บ 15inout โ€บ linux-cmd.html
Java and the Linux Command Line
You should see something similar to the information printed below. [wayne] ~> java -version java version "1.6.0_18" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0_18-112) Java HotSpot(TM) Client VM (build 1.6.0_18-64, mixed mode, sharing) Then type the following javac command.
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ programmingknowledge2
How to Run Java Program in Terminal Ubuntu 24.04 LTS Linux (2024) - YouTube
**How to Run Java Program in Terminal Ubuntu 24.04 LTS Linux Using Oracle Java**Welcome to our comprehensive tutorial on how to run a Java program in the ter...
Published ย  June 18, 2024
Views ย  1K
๐ŸŒ
DEV Community
dev.to โ€บ kirubagaran_k_438a86c991 โ€บ how-to-run-a-java-program-in-linux-terminal-4fo6
How to Run a Java Program in Linux Terminal - DEV Community
August 19, 2025 - Open the terminal. Use the command to move into the folder where your .java file is saved ... To compile, run.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ run-java-command-line-linux
How to Run Java from Command-line in Linux โ€“ Linux Hint
Compile the testing.java file on the terminal using the javac command: ... Java is the high-level language of the modern era supported by the Java Development Kit (JDK). JDK is a package that helps to run java and is used for the development of software packages.
๐ŸŒ
Medium
medium.com โ€บ @burakkocakeu โ€บ how-to-run-your-java-program-on-terminal-b4956e7102a8
How to Run your Java Program on Terminal | by Burak KOCAK | Medium
January 29, 2023 - The general syntax is java [class_name] The program will now execute and display any output in the terminal. Note that you should use the fully qualified name of the class containing the main method.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ java-how-to-compile-and-run-a-java-program-in-the-terminal-413960
How to compile and run a Java program in the terminal | LabEx
Java is a powerful and versatile programming language used across a wide range of applications. In this tutorial, we will guide you through the process of compiling and running Java programs directly in the terminal or command line interface.
๐ŸŒ
VITUX
vitux.com โ€บ your-first-java-program-in-the-ubuntu-terminal
Your First Java Program in the Ubuntu Terminal โ€“ VITUX
You can open the Terminal either through the system Dash or the Ctrl+alt+T shortcut. Since we will be installing Java through the apt utility, first let us update our apt repositories through the following command: ... This will ensure either Java Runtime Environment is already installed on ...
๐ŸŒ
Quora
quora.com โ€บ How-do-I-run-a-Java-file-in-Terminal
How to run a Java file in Terminal - Quora
Answer (1 of 3): This is an easy one to search but in short, you need the java runtime installed, as well as javac. The SDK should have both the jre and the compiler. On Ubuntu, I would run, โ€œsudo apt install openjdk-8-jdkโ€. Your java file needs to have a โ€œpublic static void main(String[] ...
๐ŸŒ
UW Computer Sciences
pages.cs.wisc.edu โ€บ ~deppeler โ€บ cs400 โ€บ readings โ€บ Linux โ€บ command_line.html
Run a Java program from the command line
cd to your program project's folder if it is already written (linux command is: cd ~/private/cs400/workspace/project/ ) If you must edit your program source code, try one of these editors ... vi (or vim - my personal favorite) vi MyProgram.java You will need to learn about modes to use vi - here's a tutorial to help you get started. Or, google vi tutorial to find many more. Java programs must be compiled and linked before they can be run. One command compiles and links all source in the current directory.
๐ŸŒ
Princeton CS
introcs.cs.princeton.edu โ€บ java โ€บ 11hello โ€บ linux.html
Hello World in Java on Linux
August 14, 2019 - To make our textbook libraries accessible to Java, use the command java-introcs instead. For example, type the following two commands to test standard drawing and standard audio: You can use Checkstyle and Findbugs to check the style of your programs and identify common bugs. To run Checkstyle, type the following command in the Terminal: Here is a list of available checks. To run Findbugs, type the following command in the Terminal: Here is a list of bug descriptions. My distribution of Linux is { Gentoo, Debian, Ubuntu, Fedora, Red Hat, SuSE, Mandriva, or Slackware }. How should I modify the instructions?