File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Works on Windows and not Solaris, Why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Works on Windows and not Solaris, Why?" Watch "Works on Windows and not Solaris, Why?" New topic
Author

Works on Windows and not Solaris, Why?

Dan Patterson
Greenhorn

Joined: Jan 27, 2005
Posts: 24
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.

Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48
So what happens when you replace

add(pane);

with

getContentPane().add(pane);

?


SCJP, SCJD
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Dan Patterson
Greenhorn

Joined: Jan 27, 2005
Posts: 24
Yep that was it.

I installed j1.5, but there was already an older version on the machine. So when I was compiling it was using the old version. Thanks.

Now it compiles fine, but when I put in an I.P and press the run button it hangs up. Do you see anything wrong in the code. I'm pretty sure it has something to do with the try/catch statement.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.
Dan Patterson
Greenhorn

Joined: Jan 27, 2005
Posts: 24
Your the man. You got it working for me. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Works on Windows and not Solaris, Why?
 
Similar Threads
Console application executing from Java
Building a simple interface
GUI
My First GUI.....maybe
Please rescue me out