[SOLVED] Why does my Java program crash when compiled

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
peter_62au
Level 1
Level 1
Posts: 17
Joined: Wed Apr 29, 2015 4:43 am

[SOLVED] Why does my Java program crash when compiled

Post by peter_62au »

Hi, I'm not sure if this is the right forum. I've got a Java program that I'm trying to port from windows to mint cinnamon. It works perfectly when run in netbeans (Linux version 8.0.2) but when I try to run the compiled jar it crashes. Any ideas?
Last edited by peter_62au on Tue May 05, 2015 8:17 am, edited 1 time in total.
User avatar
xenopeek
Level 25
Level 25
Posts: 25149
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Why does my Java program crash when compiled

Post by xenopeek »

Run it through a debugger? Fish out the stacktrace and figure out what's wrong with your program?
Image
peter_62au
Level 1
Level 1
Posts: 17
Joined: Wed Apr 29, 2015 4:43 am

Re: Why does my Java program crash when compiled

Post by peter_62au »

Probably some more info might be helpful. The program starts properly displays input boxes and accepts input but crashes as soon as it needs to access a file. But it only does this after I build the jar file and try to run it then. Within netbeans it runs perfectly with no errors. At the risk of sounding like an idiot I've only ever used netbeans and I don't know what a stacktrace is.
User avatar
xenopeek
Level 25
Level 25
Posts: 25149
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Why does my Java program crash when compiled

Post by xenopeek »

Start your Java program from the terminal. JVM should output a stacktrace there if it crashes, telling you where exactly it crashes. Usually it is sequence list of functions or methods calling each other, allowing you to figure out in which function or method the program crashed and perhaps some info on why. A debugger will do more.

Sounding like another idiot, I don't know netbeans :) Perhaps it sets up your runtime environment differently.
Image
peter_62au
Level 1
Level 1
Posts: 17
Joined: Wed Apr 29, 2015 4:43 am

Re: Why does my Java program crash when compiled

Post by peter_62au »

Managed to get it to run by using java -jar <program name> . Still won't run by double clicking the icon though. But at least I can use it now. One step closer to ditching windows. :)
Post Reply

Return to “Software & Applications”