Your way isn't far off from what I'd probably do:

Runtime r = Runtime.getRuntime();
Process p = r.exec("uname -a");
p.waitFor();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";

while ((line = b.readLine()) != null) {
  System.out.println(line);
}

b.close();

Handle whichever exceptions you care to, of course.

Answer from John Feminella on Stack Overflow
🌐
Reddit
reddit.com › r/java › java and linux system calls
r/java on Reddit: Java and linux system calls
March 10, 2025 -

I am working on large monolithic java app that copies large files from a SAN to NAS, to copy the files it uses the rsync linux command. I wouldnt have guessed to use a linux command over native java code in this scenario. Do senior java devs have a strong understanding of underlying linux commands? When optimizing java processes do senior devs weigh the option of calling linux commands directly? this is the first time encountering rsync, and I realized I should definitely know how it works/the benefits, I bought “the linux programming interface” by michael kerrisk, and it has been great in getting myself up to speed, to summarize, Im curious if senior devs are very comfortable with linux commands and if its worth being an expert on all linux commands or a few key commands?

🌐
Medium
medium.com › @a.kago1988 › system-calls-in-java-and-python-systems-an-sre-perspective-2b905c752207
Monitoring System Calls. Examples in Python and C#/.NET | by Andreas Tadashi Kagoshima | Medium
April 25, 2026 - It tells you about the operating system, the hardware, and the network beneath your application. Your profiler tells you which function is slow. Syscall tracing tells you why — and the answer almost always lives below the language runtime. And because everything is a file, a single strace session captures disk reads, network receives, pipe transfers, and device interactions in one unified stream. The same read() call, the same trace format, but radically different subsystems answering — and the duration of each call tells you which subsystem is the bottleneck.
🌐
CodeJava
codejava.net › java-se › file-io › execute-operating-system-commands-using-runtime-exec-methods
How to Execute Operating System Commands in Java
July 27, 2019 - Throughout this tutorial, you will learn how to execute a native command from within a Java program, including sending inputs to and getting outputs from the command.Basically, to execute a system command, pass the command string to the exec() method of the Runtime class.
🌐
Coderanch
coderanch.com › t › 682453 › java › System-calls
System calls? [Solved] (Beginning Java forum at Coderanch)
Adam, Good question. Java compiles into bytecode and the JVM knows how to run the bytecode. So at a low level, writing to the console is something the JVM knows how to do. (Which means calling low level system code at some point).
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › System.html
System (Java Platform SE 8 )
April 21, 2026 - First, if there is a security manager, ... is called with a RuntimePermission("setIO") permission to see if it's ok to reassign the "standard" error output stream. ... SecurityException - if a security manager exists and its checkPermission method doesn't allow reassigning of the standard error output stream. ... Returns the unique Console object associated with the current Java virtual machine, if any. ... The system console, if ...
🌐
TOPdesk Tech Blog
techblog.topdesk.com › home › understanding java native calls
Understanding Java Native Calls - TOPdesk Tech Blog
March 5, 2021 - It allows applications to call into the operating system and tell it to delete a file (see the Windows API reference on DeleteFileW for details). If you were using Unix instead of Windows, things would work pretty much the same: UnixFileSystemProvider calls UnixNativeDispatcher.unlink0, which calls unlink, which is the POSIX-way to delete a file. However, the behaviors of DeleteFileW and unlink differ in some respects. When the same Java application behaves differently on Windows and Unix, such differences can be the cause.
🌐
University of Washington
courses.washington.edu › css430 › prog › prog1_modify.html
CSS 430 - Program 1: System Calls and Shell
Java itself provides various classes and methods that invoke real OS system calls such as System.out.println and sleep. Since ThreadOS is an operating systems simulator, user programs running on ThreadOS are prohibited to use such real OS system calls.
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › core java › how to run a shell command in java
How to Run a Shell Command in Java | Baeldung
January 8, 2024 - In this article, we’ll learn how to execute a shell command from Java applications. First, we’ll use the .exec() method the Runtime class provides. Then, we’ll learn about ProcessBuilder, which is more customizable. Shell commands are OS-dependent as their behavior differs across systems.
🌐
Scribd
scribd.com › presentation › 695603037 › L4-System-Calls
Java System Calls Overview | PDF
Get the world's best ebooks, audiobooks, podcasts, magazines, documents, and more. Find anywhere else. Home to the world's documents, 300M+ and counting.
🌐
GeeksforGeeks
geeksforgeeks.org › operating systems › introduction-of-system-call
System Call - GeeksforGeeks
December 15, 2025 - These calls act as a gateway between user mode and kernel mode. System Calls are,
🌐
GeeksforGeeks
geeksforgeeks.org › operating systems › different-types-of-system-calls-in-os
Different Types of System Calls in OS - GeeksforGeeks
December 18, 2025 - Services provided by an OS are typically related to any kind of operation that a user program can perform like creation, termination, forking, moving, communication, etc. Similar types of operations are grouped into one single system call category.
Top answer
1 of 3
10

Does the JVM use system calls?

Yes.

How does it work internally to achieve its activities?

The typical pattern is that some of the methods in a Java class are labelled as native. When the JVM encounters a call to a native method it makes a call into C or C++ code that is part of the JVM executable. The native method implementation typically does the following:

  1. Check arguments from Java, and translates them into a C / C++ compatible form. For example, String arguments need to be converted to zero-terminated form.

  2. Call the standard C / C++ library function with the arguments it needs.

  3. The library function makes the syscall.

  4. The OS does its stuff and the syscall returns.

  5. The standard C / C++ library function returns.

  6. The native method implementation checks the 'errno'. If there was an error, it creates a Java exception object and throws it.

  7. Otherwise, the native method implementation converts results, etc into Java objects and returns them to the caller of the Java method.

The details vary, depending on what the native method does.

If you want to get a deeper understanding, I recommend that you checkout a copy of the OpenJDK source tree and start trawling. (You need to do the hard yards yourself ....)

2 of 3
6

Indeed, JVM needs to leverage system calls which is an operating system way to allow processes to interact with underlying system resources.

You can run strace java -version to see a bunch of system calls (mmap, mprotect, openat, etc.) executed even during this very limited java/jvm run.

Another good way to find out more is to dig trough JVM sources for native methods. One example could be an implementation of FileChannel#force method which internally calls fsync system call (for example): https://github.com/AdoptOpenJDK/openjdk-jdk11u/blob/5f01925b80ed851b133ee26fbcb07026ac04149e/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c#L172

🌐
Lenovo
lenovo.com › home
System Calls Explained: Bridging Programs and OS Tasks | Lenovo US
Languages that are closer to the hardware like C and C++ offer more direct and extensive support for system calls. Higher-level languages, such as Python or Java, abstract these details away but still offer facilities (often through libraries) to access system calls indirectly for common tasks.
🌐
IBM
ibm.com › docs › en › i › 7.4.0
IBM Documentation
This example shows how to call another Java program with java.lang.Runtime.exec(). This class calls the Hello program that is shipped as part of the IBM Developer Kit for Java. When the Hello class writes to System.out, this program gets a handle to the stream and can read from it.
🌐
UCSD
cseweb.ucsd.edu › classes › sp23 › cse120-a › projects › project2.html
CSE 120: Principles of Computer Operating Systems
In a real operating system, the kernel not only uses its procedures internally, but allows user-level programs to access some of its routines via system calls. The goal of this project is to enable user-level programs to invoke Nachos routines that you implement in the Nachos kernel. ... UserKernel.java - a multiprogramming kernel.
🌐
YouTube
youtube.com › charles edeki -- math computer science programming
Operating System Concepts: System Calls and Type of System Calls, Context Switch - YouTube
A system call is a request made by a program to the operating system. It allows an application to access functions and commands from the operating system's A...
Published   October 14, 2021
Views   1K
🌐
Wikipedia
en.wikipedia.org › wiki › System_call
System call - Wikipedia
3 weeks ago - This may include hardware-related services (for example, accessing a hard disk drive or accessing the device's camera), creation and execution of new processes, and communication with integral kernel services such as process scheduling. System calls provide an essential interface between a ...
🌐
Medium
medium.com › @yigitalpalakoc › the-power-of-system-calls-and-multi-threading-in-operating-systems-85d1835d012
The Power of System Calls and Multi-Threading in Operating Systems | by Yiğit Alp Alakoç | Medium
September 12, 2023 - System Calls in Java: Java provides a platform-independent way to access system calls through its standard library. The `java.lang` package includes classes like `ProcessBuilder` and `Runtime` that allow you to execute system commands and manage processes.