If you use Java like most other programming languages, e.g. to write standalone applications, it is no less secure than other languages and more secure than C or C++ because of no buffer overflows etc.

But Java is regularly used as a plugin inside the web browser, e.g. similar to Flash. Because in this case the user runs untrusted code without having explicitly installed it, the idea is to have the code run inside a limited sandbox, where it should not be able to somehow act against the system or the user (e.g. read local files and send them to the website, scan the local network etc). And this is where Java failed in the recent years, e.g. new bugs popped up sometimes on a daily basis which allowed escaping from the sandbox.

Also, sometimes bugs in the byte code interpreter or native libraries lead to buffer overflows and could compromise the system, but in this regard Flash is usually considered worse.

And as for the other languages being better: these usually can't even run as untrusted code inside a sandbox (exception is JavaScript and maybe Flash), so they would be even worse because there is no inherent way to limit their interaction with the system.

Answer from Steffen Ullrich on Stack Exchange
Top answer
1 of 8
124

If you use Java like most other programming languages, e.g. to write standalone applications, it is no less secure than other languages and more secure than C or C++ because of no buffer overflows etc.

But Java is regularly used as a plugin inside the web browser, e.g. similar to Flash. Because in this case the user runs untrusted code without having explicitly installed it, the idea is to have the code run inside a limited sandbox, where it should not be able to somehow act against the system or the user (e.g. read local files and send them to the website, scan the local network etc). And this is where Java failed in the recent years, e.g. new bugs popped up sometimes on a daily basis which allowed escaping from the sandbox.

Also, sometimes bugs in the byte code interpreter or native libraries lead to buffer overflows and could compromise the system, but in this regard Flash is usually considered worse.

And as for the other languages being better: these usually can't even run as untrusted code inside a sandbox (exception is JavaScript and maybe Flash), so they would be even worse because there is no inherent way to limit their interaction with the system.

2 of 8
83

The security vulnerabilites reported are not about Java (the programming language), which, by virtue of the JVM enforcing memory safety, is actually more robust than languages such as C or C++, where buffer overflows and buffer over-reads remain a threat, and can result in messes like Heartbleed.

Instead, the vulnerabilites reported are in the Java Sandbox, which attempts to enforce a priviledge model that permits safe execution of untrusted code, and is most famously used to permit the automatic execution of Java Applets in a browser. That sandbox is riddled with holes. Also, Oracle releases patches (the "critical patch updates") only 4 times a year. Needless to say to browser vendors are not happy about this. Firefox, for instance, is requiring user authorisation to launch a Java Applet since Firefox 26.

The reason the press reports do not make that distinction is that Oracle uses the "Java" trademark both for the programming language, and the browser plugin that runs applets. In fact, if an ordinary user encounters the Java trademark, it probably refers to the latter.

It is somewhat speculative why exactly the Sandbox remains vulnerable. If you ask me, one reason is that the same API is used both with and without the Sandbox, and most Java code runs without the Sandbox (because the code is trusted). As a result, it is quite possible for a developer to forget about that obscure feature when changing the Java API or its implementation, accidentally exposing things that should be protected (to illustrate how easy that is, behold the lengthy Secure Coding Guidelines for Java SE). Another but related reason is the sheer size of the Java API (5800 classes, and nearly 50,000 methods, for Java SE 6).

🌐
GeeksforGeeks
geeksforgeeks.org › gblog › why-java-is-secure
Why Java is Secure? - GeeksforGeeks
July 23, 2025 - Java, a programming language developed by Sun Microsystems, which is a property of Oracle Corporation now, is considered to be maximally protected from moments of vulnerability. Java was developed in the mid-1990s, and security was given significant ...
🌐
Medium
rameshfadatare.medium.com › why-is-java-secure-java-interview-question-and-answer-53ef392f82f8
Why is Java Secure? (Java Interview Question and Answer) | by Ramesh Fadatare | Medium
March 21, 2025 - Java is considered secure because of its runtime environment (JVM), absence of pointers, bytecode verification, security APIs, and a built-in security manager that restricts access to system resources.
🌐
Educative
educative.io › blog › why-java-is-more-secure-than-other-languages
11 reasons why Java is more secure than other languages
The demand for Java developers ... Java’s unmatched security capabilities are the main reason so many companies are using it. With features like private transmission, automatic memory management and corruption prevention, Java is a great choice for anyone worried about security...
🌐
Wordpress
littlemaninmyhead.wordpress.com › 2021 › 01 › 28 › no-java-is-not-a-secure-programming-language
No, Java is not a Secure Programming Language – Little Man In My Head
January 28, 2021 - If you ask Google, you will be brought to a fantasy land of fairies, unicorns, and Java being the quintessential example of a secure programming language. Whoever are writing these web pages clearly do not live in the same world as me — an Application Security Specialist (there is no acronym for that title, BTW) who spends his every day with developers to help them uplift secure coding practices.
🌐
Temok
temok.com › blog › is-java-safe
Is Java Safe: Outdated Language or Still Secure in 2025?
September 7, 2025 - Is Java safe in 2025? Explore security flaws, features, and whether Java is outdated or still a reliable choice for developers.
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › security › java-security-overview1.html
Java Security Overview
2 weeks ago - At its core, the Java language itself is type-safe and provides automatic garbage collection, enhancing the robustness of application code. A secure class loading and verification mechanism ensures that only legitimate Java code is executed.
🌐
Edureka
edureka.co › blog › why-java-is-secure
Why Java is Secure? Top 10 Java Features that makes it Secure | Edureka
September 27, 2023 - Java virtual machine plays a fundamental role to verify the byte-code. The task of JVM is to check that the program is not making any unsafe operations. There are cases when a program jumps to wrong locations that can hold malicious data. The JVM guarantees that such kind of unsafe operations do not exist. The JVM helps to diminish the possibilities of the developers who suffer from memory safety flaws. Let’s understand Security API’s.
🌐
TutorialsPoint
tutorialspoint.com › why-java-is-a-secure-programming-language
Why Java is a Secure Programming Language?
August 6, 2024 - For example, Java's access control model allows developers to restrict access to certain parts of an application based on user roles. It helps to ensure that only authorized users can gain access to sensitive data. Overall, Java is an incredibly secure language & millions of developers use it.
🌐
Software Engineering Institute
sei.cmu.edu › blog › is-java-more-secure-than-c
Is Java More Secure than C? - Software Engineering Institute
October 5, 2015 - In contrast, C has a long and sordid history of exploits going back to the late 1980s (and probably earlier). For these reasons, Java is often considered more secure. For this analysis, I decided to focus on the most critical rules in the C and Java coding standards.
🌐
Oracle
java.com › en › security › developer-info.jsp
What Developers Need to Know About Java Security
Java is the most powerful tool you can use as a developer to deliver full featured applications to your users. Developing with Java allows you to create very powerful applications. To make sure these applications are secure, you need to engage some development best practices.
🌐
Medium
yuudaiishihara.medium.com › why-java-is-considered-one-of-the-most-secure-programming-languages-7f4e9976f3e5
Why Java Is Considered One of the Most Secure Programming Languages | by Yuudai Ishihara | Medium
October 5, 2023 - With the increasing frequency and sophistication of cyber threats, choosing a secure programming language is a critical decision. Java has long been recognized as one of the most secure programming languages available, and in this article, we’ll ...
🌐
Ksolves
ksolves.com › blog › java › why-java-is-more-secure-than-other-languages
Why Java Is More Secure Than Other Languages? | Ksolves
February 1, 2025 - With Java security features such as automatic memory management, private transmission, and corruption prevention, Java becomes a great option for anyone worried about security. The use of pointer values for managing application memory and protecting ...
🌐
Snyk
snyk.io › articles › java-security
Java Security in 2023- Snyk | Snyk
September 14, 2022 - Both the Java language itself, along with additional features offered inside the Java Security package, make it an overall secure platform to use. The Java language itself is inherently secure in many ways.
🌐
Quora
quora.com › What-is-Java-How-is-Java-a-secure-language
What is Java? How is Java a secure language? - Quora
Java is a high level, robust, object-oriented and secure programming language.Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. In this section, we are going to discuss why Java is secu...
🌐
Javatpoint
javatpoint.com › why-java-is-secure
Why Java is Secure - Javatpoint
Why Java is Secure with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
InfoWorld
infoworld.com › home › software development › programming languages › java
How secure is Java compared to other languages? | InfoWorld
April 21, 2020 - Reading the research on security vulnerabilities might make your heart beat faster, but fear not: Java developers are in a strong position when it comes to application security. With thousands of pros scanning the language for vulnerabilities, ...
🌐
Oracle
docs.oracle.com › javase › 7 › docs › technotes › guides › security › overview › jsoverview.html
Overview of Java SE Security
The Java™ platform was designed with a strong emphasis on security. At its core, the Java language itself is type-safe and provides automatic garbage collection, enhancing the robustness of application code.