I wrote this program on a windows machine, but it is used on a Solaris 8 machine. I used J2SE 1.5 to write this, and both machines are running 1.5 VM. It compiles fine on windows, the gui comes up, obviouslt I cant run it cause it executes a bash shell to run a script. When I compile it on Solaris I get this error.
OrderVodScript.java:15: No variable EXIT_ON_CLOSE defined in class javax.swing.JFrame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ^ 1 error
If I remove this line, it will compile with no errors, but when I run it I get this. Exception in thread "main" java.lang.Error: Do not use OrderVodScript.add() use OrderVodScript.getContentPane().add() instead at java.lang.Throwable.fillInStackTrace(Native Method) at java.lang.Throwable.fillInStackTrace(Compiled Code) at java.lang.Throwable.<init>(Compiled Code) at java.lang.Error.<init>(Error.java:50) at javax.swing.JFrame.createRootPaneException(JFrame.java:333) at javax.swing.JFrame.addImpl(JFrame.java:355) at java.awt.Container.add(Container.java:211) at OrderVodScript.<init>(OrderVodScript.java:24) at OrderVodScript.main(OrderVodScript.java:65)
Any help is greatly appreciated. Here is the code.
Your assumption about 1.5 on Solaris is wrong. EXIT_ON_CLOSE was added in JDK 1.4, and the add()/getContentPane().add() thing was changed in 1.5. So you've got both a compiler error and a runtime error that indicate you're using JDK 1.2 or 1.3 on Solaris.
I see a number of things. First, the command you're sending to bash has no newline at the end, so bash will just sit and want for a complete line. Your program will hang.
If you add the newline, i.e., write("somecommand\n"), then the command will be executed, but bash still won't exit -- because you never tell it to. You could send an "exit\n" and then close the output stream.
If you do that, you'll still have a problem because I imagine the testvodscript script wants the actual entered IP as an argument, not the characters "((ip))", which is what it will see. You need to do something like
outCommand.write("testvodscript " + ip);
If the script produces any output, you won't see it. You'll need to get an output stream from the Process object and read the output from there.
Finally, if anything goes wrong at runtime, your catch blocks see to it that the program will exit silently, leaving you wondering what went wrong. Don't exit without reporting the error -- use e.printStackTrace(), at least, so you see what happened.