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
Discussions

How to automate running a script on startup in EC2?
  • i assume u have java installed on your box already

  • give the full path of java in the script, instead of "java -Xmx" give the full path "/usr/local/bin/java -Xms" , find out your path "which java" and use that

More on reddit.com
🌐 r/aws
2
5
November 16, 2017
Trying (and failing) to run cURL command in JAVA using ProcessBuilder
You aren't doing anything with the output, so while it may be working fine there's no way to tell. You need to store the output in a variable to use it or redirect it to stdout if you just want to have it printed to the console. Also remove the quotes. They are needed for a shell to interpret the input correctly but you are launching the process directly and not going through a shell. This means that the quotes are being part of the url curl is trying to access. More on reddit.com
🌐 r/javahelp
7
5
October 10, 2017
installed java on linux but cannot run java applications
That's not how jar applications work. That would work with a script or binary but java has to interpret the jar for you. Open a terminal and run it like this in a terminal. java -jar /home/user/application.jar More on reddit.com
🌐 r/linuxquestions
4
0
October 1, 2022
How to install Java?
I think the first command will install the LTS version, which is currently 11. This has always been confusing on Debian distros. Are you just running java? Or are you looking to build new java code? Install the jdk if you want to build, not the jre. More on reddit.com
🌐 r/pop_os
4
5
February 25, 2020
🌐
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.
🌐
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 - In this tutorial, we will learn about how to run a command-line Java program from the Linux terminal.
🌐
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 - This is incredibly useful for quick scripts, prototyping, or executing utility code without cluttering your directory with .class files. Delete the compiled class file to prove it works: fosslinux@dev:~$ rm Main.class fosslinux@dev:~$ java Main.java Executing Java directly from the Linux CLI. Java version: 21.0.2
🌐
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.
🌐
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.
Find elsewhere
🌐
Linux Hint
linuxhint.com › run-java-command-line-linux
How to Run Java from Command-line in Linux – Linux Hint
(Keep in mind that your class name should be the same as the file name) 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.
🌐
YouTube
youtube.com › watch
how to compile and run java code on linux - YouTube
This video shows how to install gedit, java jre and java jdk on linux (mainly linux mint). It, also, shows how to compile java files using the linux terminal...
Published   March 4, 2019
🌐
Princeton CS
introcs.cs.princeton.edu › java › linux
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?
🌐
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 [...]
🌐
Oracle
java.com › en › download › help › linux_install.html
How do I download and install 32-bit Java for Linux?
Java on RPM-based Linux Platforms This installs the Java Runtime Environment (JRE) for 32-bit RPM-based Linux platforms, such as Red Hat and SuSE, using an RPM binary file (.rpm) in the system location. You must be root to perform this installation. Download the package that best suits your needs.
🌐
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.
🌐
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.
🌐
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
🌐
Silicon Cloud
silicloud.com › home › run java in linux: step-by-step guide
Run Java in Linux: Step-by-Step Guide - Blog - Silicon Cloud
August 2, 2025 - Learn how to run Java programs in Linux. Simple commands to compile and execute Java files in terminal.
🌐
Oracle
java.com › en › download › help › enable_console_linux.html
How do I enable and view the Java Console for Linux or Solaris?
You can enable the Java Console for the Linux and Solaris platforms through the Java Control Panel · Open a Terminal window. Go to the Java installation directory. In this example Java is installed in the /usr/java/ directory.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-execute-and-run-java-code
How to Execute and Run Java Code from the Terminal
March 10, 2022 - Then we need to execute/run the class file. We need to use the command javac file_name_with_the_extension. For example, as I want to compile my Main.java, I will use the command javac Main.java.
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › install-java-linux
How to Install Java on Linux: Step By Step Installation Guide
April 23, 2026 - Check out this blog on how to Install Java on Linux, where we will provide you with clear instructions on downloading and installing Java on Linux. ... The Java Virtual Machine (JVM)), Java Runtime Environment (JRE), and Java Development Kit (JDK) are different software bundles for running Java programs with extra functionalities.