This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes problem regarding batch file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem regarding batch file" Watch "problem regarding batch file" New topic
Author

problem regarding batch file

pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
i have to execute two batch files.after the first batch file is executed and after some time second batch file should be executed .when iam giving wait() for second batch exception is comming
Process p1=r.exec("d:/surya/a.bat");
Process p2=r.exec("c:/suresh/c.bat");
the exception is
java.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:429)
at swings.swing1.actionPerformed(swing1.java:184)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

please tellme what is the problem.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Do you understand why one of the following methods works and the other
throws that exception?


There is no emoticon for what I am feeling!
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
when i executed your program no output is comming. when synchronized keyword is given one method is executed after the other.but inmy program also i have givenlike that.but the exception is comming.please tellme how to solve this problem
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

The answer is, I think, that wait() doesn't do what you think it does. Rather than teach you about wait(), I'll just tell you that the correct method for you to use is the static Thread.sleep() method. You'll have to catch InterruptedException when you call it.


[Jess in Action][AskingGoodQuestions]
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
my program is using swings.iam not using threads.if i have to use threads ia have to implement runnable interface.when iam giving that interface it is giving error as classname is not abstract and does not override run(). if i have given my class name as abstract we should not create an object for that class.but iam instantiating my class.please tell me how to solve this problem.my class is extending JFrame.so we should not give extends Thread class
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

As I said, Thread.sleep() is a static method. Just call it.



You don't need to use Threads otherwise.

Of course, you shouldn't sleep or wait (or execute processes, for that matter!) on the event thread, as this will make your program appear to "lock up." You need to do this kind of thing in a separate thread anyway.
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
according to your suggestion i have called Thread.sleep(10000)eventhough the eception is raising.iam providing that exception also
ava.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.notify(Native Method)
at swings.swing1.actionPerformed(swing1.java:190)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
please help me to solve this as iam trying for this since 1 day
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Originally posted by pvsr rao:

java.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.notify(Native Method)
at swings.swing1.actionPerformed(swing1.java:190)


This trace says that at line 190 of swing1.java, you're calling "notify" without holding the monitor of the object on which you're calling it -- i.e., you're calling x.notify() outside of a synchronized method of x or a synchronized(x) block.

Now why are you calling "notify", if you're no longer calling "wait"?
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
Thankyou for sending. i have forgotten to delete notify().now it is working fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem regarding batch file
 
Similar Threads
iam hetting error when compile a File open service
JInternalFrame
internal frame
Interesting error with CipherInputStream
how to use parseInt()