Without using any external libraries, does Java, including all officially supported APIs give you enough to develop fully-featured 2D games? The reason I ask is that I hear a lot of "bad-mouthing" about Java and game development, but I'm wondering if that is only in regard to intensive 3D games. Also reading up on some Java games there often appears to be external graphics or sound libraries involved that simply have a Java port. This makes me think it isn't possible.

  • 9
    \$\begingroup\$ What is wrong with external libraries? \$\endgroup\$ – AttackingHobo Apr 11 '11 at 21:20
  • 2
    \$\begingroup\$ Any language which can do any type of output can be used to make a 2D game... Console output and ASCII Art... \$\endgroup\$ – Nate Apr 11 '11 at 22:14
  • \$\begingroup\$ Can you clarify what kind of features you're looking for? \$\endgroup\$ – Tim Holt Apr 11 '11 at 23:24
  • \$\begingroup\$ @AttackingHobo: It wasn't necessarily that there is anything wrong with libraries, but I know Java, and if I can stick to the core API for graphics and sound without having to learn an external API as well, then that is always a plus. \$\endgroup\$ – user6214 Apr 12 '11 at 0:42
  • 3
    \$\begingroup\$ There are 2D java game libraries that would make your job much easier than coding it your self. I mean it is possible, but why waste 1000s of man hours that have been put into proven, fast 2D renderers. \$\endgroup\$ – AttackingHobo Apr 13 '11 at 3:08

In 2011 any language with bindings to OpenGL is more than capable of a "2D game" in the style of Nintendo from the 1990s or so, when running on a desktop PC made in this millennium.

For TV game consoles, the only language available for development across all platforms is C++, so that's what people use for the most complex 3D games and the simplest 2D games. Java would work for simpler games, but C++ is the compromise we live with to avoid the cost of supporting more than one language.

For handheld devices (and to a lesser extent TV game consoles) performance is critical often enough that the overhead imposed by Java et al. can't be tolerated for games with medium or high complexity.

Android phones do run games in Java, but there is a clear trend recently toward "native" C++ games on Android, not primarily for performance, but because ironically Java isn't as "platform-independent" as C++. All non-Android platforms use some kind of C/OpenGL, and porting a game among them is fairly cheap. Porting from any of them to Android/Java is relatively expensive.

  • \$\begingroup\$ Java overhead is nearly zero these days. It even performs dynamic casts faster than C++ because the type information is stored inside the object data header . \$\endgroup\$ – luke1985 Apr 4 '14 at 13:09

In theory, nothing.

In practice, mainly the fact that not a lot of people have done it already. If you're looking for code samples or documentation you'll more likely find code written in C or C++ instead of Java.


There's nothing missing from Java that is required to make a fully featured 2d game. There are definitely games written in Java that don't use external libraries, or, use them sparingly. Most of the complaints people tend to make about Java are either the slowness of games vs C or C++ (valid, but computer speed is fast enough to make the point moot), or personal frustrations with Java (almost everyone has a language they like to hate...). Java also has a reputation for being a 'business' programming language.

The only issues that might come up from using Java is hardware acceleration. If Java's native graphics rendering is not hardware accelerated, then you'd be risking performance problems. External libraries can often solve this problem.

  • \$\begingroup\$ These days, in many cases the standard graphic classess are backed up by hardware acceleration. So in this case, no JNI extensions are needed. Example is my 5 years old PC drawing a hardware accelerated instance of BufferedImage on the screen about 20 000 each iteration at 200 fps. Using JDK 7 \$\endgroup\$ – luke1985 Apr 4 '14 at 13:15

Of course you can. But some boring stuff you have to do at your own.

I read a book, 'killer game programming in java', and there was no external library, just Java2D. I also developed an arcade game with it...

Java can be an engine IMO, but you should really prefer another engine, which is built on top of this stuff and OpenGL.

I am currently using libGDX for my android game and I am happy so far. With it you can develop simultaneously for android and PC ;)

  • 1
    \$\begingroup\$ Keep in mind you can write boring stuff in any language, and that a lot of exciting stuff "back in the day" got written in assembly language. \$\endgroup\$ – Tim Holt Apr 11 '11 at 23:08

For modern high quality 2D graphics you'd often use 3D rendering, meaning you'd need a 3rd part 3D library for most languages anyway.

I think mostly for game development Java just doesn't do a lot that C++ or C# doesn't do, and it might be a little slower than C#.

A lot of people seem to have very strong opinions on what is good for what and what isn't, it's often a sign that they simply don't know what they are talking about.

  • 3
    \$\begingroup\$ "For modern high quality 2D graphics you'd almost always be using 3D rendering" This makes no sense to me. There are LOTS AND LOTS of 2D games that have nothing to do with 3D rendering or styles. \$\endgroup\$ – Tim Holt Apr 11 '11 at 23:06
  • \$\begingroup\$ Of course there are still games that use pure 2D, mostly small stuff. 3D gives easy to use rotation and scaling, if you need just one of those features it's the easy and performing choice. What recent high graphics quality 2D games have been made using pure 2d? \$\endgroup\$ – aaaaaaaaaaaa Apr 11 '11 at 23:53
  • \$\begingroup\$ Pokemon heart gold, soul silver, black and white are good examples of 2.5d games. Zenonia 2 (android) is an example for 2d games with good graphics. \$\endgroup\$ – Marco Apr 12 '11 at 10:05
  • \$\begingroup\$ ". What recent high graphics quality 2D games have been made using pure 2d?" => vector graphics (ie mostly Flash, but also other Macromedia and non Macromedia products), see many experimental Flash games. \$\endgroup\$ – jv42 Apr 12 '11 at 11:33
  • \$\begingroup\$ Flash is GPU accelerated these days, the Nintendo DS seems to be a platform where pure 2D still lives (does it even have hardware accelerated rotation and scaling?). Of course one could argue that the mobile 2D games does not meet the high quality graphics criterion, but that is a subjective argument. My point was mainly that for 2D games on desktop and consoles one should consider using 3D acceleration. \$\endgroup\$ – aaaaaaaaaaaa Apr 12 '11 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy