I've been having problems building my game. I've built it successfully before, until I added the LuaJava.dll and LuaJava.jar files (so I can use Lua in my game).

Now, it just briefly opens with black screen and immediately closes. Even though it works just fine in Eclipse.

What I used to do before, was set my jar file in my assets and it would just work fine. But now, it refuses to work, and I have no idea what the error is.

Is there a function I can call to output the error into a log file?

  • \$\begingroup\$ could you clarify what you mean by "set my jar file in my assets"? Jar files need to be added to the build path and should not be loaded as an asset. \$\endgroup\$ Dec 15, 2015 at 23:07

2 Answers 2


I don't know about writing an error log on crash, but all Android apps already log to the built-in logger. You just need an app like CatLog to view them.

Although verbose, you can usually filter by namespace (and see logs only related to your application). Eclipse does something similar with the built-in log viewer.

This is the only log viewer I used when I worked on my libGDX games.

  • \$\begingroup\$ My project is a desktop project though. \$\endgroup\$ Dec 17, 2015 at 20:16
  • \$\begingroup\$ @GigaNova are you able to debug it with the Eclipse debugger? \$\endgroup\$
    – ashes999
    Dec 17, 2015 at 20:20
  • \$\begingroup\$ ofcourse, but I'm running a compiler Jar file. \$\endgroup\$ Dec 17, 2015 at 21:17
  • \$\begingroup\$ @GigaNova you should be able to set breakpoints and debug to the line that's terminating/failing. You should also be able to see some sort of exception (albeit maybe a runtime one) explaining why it's crashing. \$\endgroup\$
    – ashes999
    Dec 17, 2015 at 22:35
  • \$\begingroup\$ Again, it works completely fine in Eclipse, It's the compiled Jar that doesn't work. \$\endgroup\$ Dec 18, 2015 at 7:58

Solution 1

What I do to log errors is to surround my render() method with a try and catch block that catches the default Exception class. This writes a simple time-stamped log file. It can be implemented like this (Java 7+ Only):

public void render() {
    try(BufferedWriter writer = new BufferedWriter(new FileWriter(new SimpleDateFormat("ddMMyyHHmmss").format() + ".log") {
        //Code here
    } catch(Exception e) {

Solution 2

You can run the program on the console using the java -jar {jarname}.jar command on the command line to see the error log.

Hope this helps! ~ Ammar Tarajia

P.S: On Windows, to navigate to the correct directory, just do the cd command then the folder. (Don't include the drive code!)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .