• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Quick Java question

LeetestUnleet

Senior member
First, it's not really my program, a friend of mine is having troubles and he asked me for help, but my solution isn't working. Basically, he just wants to execute different programs/scripts from one java program. He's running linux. We tried this:

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
Runtime.getRuntime().exec("/usr/local/bin/ballsmacker");
}

But it gives this error:

funnny.java [119:1] unreported exception java.io.IOException; must be caught or declared to be thrown
Runtime.getRuntime().exec("/usr/local/bin/ballsmacker");
 
you have to put it in a try block and catch an Exception in case it cannot find the file you try and run or any other various errors that might pop up.

-silver
 
Ah, we've got it figured out now.

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

try{
Runtime.getRuntime().exec("/usr/local/bin/ballsmacker");
}catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}

Thanks for the tip-off!
 
Back
Top