Blog

IS JAVA VIABLE FOR GAME ENGINES?

If you are into game development, you’ve probably already wondered what programming language you should use and what are some game engines options out there. Since Java is a popular language (and a popular choice for beginners) let’s look at its viability in the gaming field.  

 

There is an opinion, circling in the professional community, that Java sucks for gaming. Game developers do not like Java because it was not originally made for game engines. Some of devs complain that you might need to write your own code even for the most basic tasks, others call the game-related frameworks poorly developed. But before we jump to any judgments let’s look at some popular games built with the use of Java. The list is actually pretty impressive. 

 

WHAT IS THE TOP 5 GAMES CREATED IN JAVA? 

 

  1. WORMS W.M.D. (a hand-drawn 2D artillery turn-based tactics video game). 
  2. SAINTS ROW (a mission-based game with a gameplay similar to GTA). 
  3. SIMCITY (an open-ended city-building game). 
  4. SPIRAL KNIGHTS (an online multiplayer quest for battling monsters and collecting treasure). 
  5. MINECRAFT (famous sandbox video game with infinite worlds). 

 

WHAT ARE THE BEST GAME ENGINES FOR JAVA? 

 

Though, as mentioned before, it wasn’t meant for gaming, Java language has found its way into several game engines over the years. Overall, if we are to name the most solid ones, powered by Java, it's: 

 

  1. LibGdx (a cross-platform Java game development framework based on OpenGL that works on Windows, Linux, macOS, Android, your browser and iOS). 
  2. JMonkeyEngine (made especially for modern 3D development with extensive use of shader technology). 

 

SOME PROBLEMS OF JAVA USE FOR GAMING  

 

Boasting powerful game engines and highly popular games built around them, Java still is not the first choice of game devs. Let’s see why. 

 

  • Garbage collector 

Java's use of garbage collection is a red flag for game developers. When each game cycle has to run in 1/60th second, a non-deterministic mark-and-sweep clean up can take 0,25 seconds. For games like Counter-Strike: Global Offensive it is simply too slow. 

 

  • Limited 3rd party libraries 

Most of the available libraries are not meant to support Java. On the other hand, Java has a huge in-built library, reducing the need for third party libraries that are not game related.  

 

  • No support for game consoles 

On a positive side, Android, being a huge mobile platform, uses some form of Java. It’s a good option, but it doesn’t mean that the same Java code will work both on a PC and Android device. 

 

  • Smaller community 

A majority of game programmers use C++ and often dislike Java. So, don't expect to get much help from colleagues. Another thing you shouldn’t hope for is getting a job in game development without C++ skills. 

 

CAN I STILL USE JAVA FOR GAME DEVELOPMENT? 

 

Well, there is a dilemma between could and should.  There’s certainly no reason you couldn’t use Java for creating a game. Yes, it doesn’t have the best industry support (that would be C++), but let’s look at Minecraft. It is one of the most successful games in the history of video gaming. It was created and is still maintained in Java.  

 

SHOULD I USE JAVA? 

 

It depends on what type of game you are trying to build.  

Java isn’t a perfect choice for high-end or e-sport video games due to some JVM (Java virtual machine) limitations. Sure, garbage collection is a good help with complex data structures, but its activity can cause performance glitches that are unacceptable in, say, League of Legends or Counter Strike.  

There’s a lot of convenience features in Java (including a notable lack of pointers) that can impose performance ceilings into some other video game designs, like ones with massive draw call demands (open-world games) or programmatic, real-time 3D model manipulation (physics games). 

 

HOW DO I USE JAVA FOR GAME DEVELOPMENT? 

 

If you have a smaller project and such performance minuses aren’t a problem, Java can be used in two main ways: 

 

  1. you can build a game from scratch, using LWJGL library for 3D or even JavaFX for 2D (just like how Minecraft was made); 
  2. you can use available video game engines like JMonkeyEngine or LibGDX (which is actually more of a framework), which are the most “mature” and best developed engines for Java today. 

 

CONCLUSION: 

 

The choice of Java is pretty much viable if you are not creating high-class big-budget video games (called AAA or Triple-A in the industry). In other words, if your game doesn’t have heavy graphics and endless worlds and you are determined to use Java to build it, go for it. 

 

But, if you are looking for a full-powered and well-featured game engine, both Unreal Engine and Unity are your best bets.  

 

Unity uses C#, which is actually not a far derivative from Java and could be learned quickly. Unreal Engine uses C++ and visual scripting called Blueprints enabling a faster drag-and-drop programming feature. Before they had some performance issues, but with recent improvements to the Blueprint compiler, it’s now similar or even faster than your typical scripting language.