The Runtime.exec methods doesn't work well on Solaris ???

I have two threads and I set the different running time.
I use Runtime.exec to a run the command and use Process to get the process.
It works properly in the windows2000 platform.
However, when I transfer the platform to Solaris...and run the program...
Two threads always at the same time....It is very wired....I always debug
for 2 days....
(at first I run "vmstat 1 2" command, later I change to "ls","rmdir"....etc,
all of them don't work.....
If I close the Runtime.exec..........Everything works well......)
And I study the API. I found this message...
The Runtime.exec methods may not work well for special processes on certain
native platforms, such as native windowing processes, daemon processes,
Win16/DOS processes on Win32, or shell scripts. The created subprocess does
not have its own terminal or console.
Could someone share her/his experience.....:(
And if any other way I can run command inside java code instead of
Runtime.exec.....???
Please reply my mail to [email protected] I do appreciate your kindly &
great help!!!!!!!!
This is my code.......
import java.io.*;
import java.lang.*;
import java.util.*;
* <p>ServerThread1</p>
* <p>??�X???��?�D???�X???, "Vmstat 1 2".</p>
class ServerThread1 extends Thread{
private ServerAgent Sa;
public ServerThread1 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa; file://Assign ServerAgent reference Sa
public void run(){
while(true){
try{
Thread.sleep(5000);
catch (Exception e){
System.out.println("ServerThread1 fails");
System.out.println("Thread1 is running.");
try {
Runtime rt1 = Runtime.getRuntime();
Process proc1 = rt1.exec("mkdir"); ------>If I close
rt1.exec , two threads works seperately...........:(
catch (Exception e) {
System.out.println("Thread1 Error");
class ServerThread2 extends Thread{
private ServerAgent Sa;
public ServerThread2 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa;
public void run(){
while(true){
try{
Thread.sleep(15000);
catch (Exception e){
System.out.println("ServerThread2 fails");
System.out.println("Thread2 is running.");
try {
Runtime rt2 = Runtime.getRuntime();
Process proc2 = rt2.exec("vmstat 1 2"); ----->If I don't run
the rt2.exe, two threads work seperately....
catch (Exception e) {
System.out.println("Thread2 Error");
public class ServerAgent{
private Vector v1 = new Vector();
private Vector v2 = new Vector();
private Hashtable currentData = new Hashtable();
private static String startUpSwap = null;
private static String startUpMem = null;
public static void main(String[] arg) {
ServerAgent s = new ServerAgent();
ServerThread1 st1 = new ServerThread1("Thread1",s);
ServerThread2 st2 = new ServerThread2("Thread2",s);
st1.start();
st2.start();

If I close the Runtime.exec..........Everything works
well......)You don't empty the output of the command, that blocks the process.
A citation from
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Why Runtime.exec() hangs
The JDK's Javadoc documentation provides the answer to this question:
Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
Try out something like this:
String s;
try {
   Process myProcess =
   Runtime.getRuntime().exec("ls -l"));
   DataInputStream in = new DataInputStream(
          new BufferedInputStream(myProcess.getInputStream()));
    while ((s = in.readLine()) != null) {
        out.println(s);
catch (IOException e) {
    out.println("Error: " + e);
}Another source of trouble under Unix is not having the correct permission for that user that executes the Java VM, which will be the permissions for the spawned subprocess. But this probably not the case, as you see something after exit.
Regards,
Marc

Similar Messages

  • The new nano software doesn't works well

    I have installed the last version of the software of the Ipod nano and I cannot ignite the light of the screen when I push menu (during 3 sec). Obviously it is a bug of the new software because before the update worked well.

    I know HOLY took me days to figure out how to fix it... if you have a mac i dont know how to fix but if you have Windows click on all programs on the start menu then look up ipod then click on the update b4 the one that you installed and it should give you and option to restore ... as it will i will come back as factory bought it will have no songs on it so you have to re add your song which wont take long

  • Why the bluetooth function on the iPad (4th Gen) doesn't work well to pair either with my PC (Windows7) or iPhone4 running on iOS7 ?

    Why is it that my iPad(4th Gen) doesn't pair either with PC ( Windows7) or iPhone4 (running iOS7)?
    The search for the devices on turning Bluetooth is eternal and the activity ring keeps swirling for ever to leave frustrated.

    I'm sorry but Bluetooth on iPad/iPhone doesn't work as you'd expect it too, particularly if you've used Nokia or other brands in the past.  Bluetooth on iPad/iPhone will only allow you to add other devices such as keyboards or headsets.
    Regards,
    Steve

  • LVOOP "call parent method" doesn't work when used in sibling VI

    It seems to me that the "call parent method" doesn't work properly according to the description given in the LabVIEW help.
    I have two basic OOP functions I am doing examples for. I can get one to work easily and the other one is impossible.
    Background
    There are 3 basic situations in which you could use the "call parent method"
    You are calling the parent VI (or method) of a child VI from within the child VI
    You are calling the parent VI (or method) of a child VI from within a sibling VI
    You are calling the parent VI (or method) of a child VI from a different class/object.
    From the LabVIEW help system for "call parent method":
    Calls the nearest ancestor implementation of a class method. You can use the Call Parent Method node only on the block diagram of a member VI that belongs to a class that inherits member VIs from an ancestor class. The child member VI must be a dynamic dispatching member VI and have the same name as the ancestor member VI
    From my reading of that it means situation 3 is not supported but 1 & 2 should be.
    Unfortunately only Situation 1 works in LabVIEW 2012.
    Here is what I want
    And this is what I actually get
    What this means is that I can perform a classic "Extend Method" where a child VI will use the parent's implementation to augment it's functions BUT I cannot perform a "Revert Method" where I call the parent method's implementation rather than the one that belongs to the object.
    If you want a picture
    Any time I try and make operation2 the VI with the "call parent method" it shows up for about 1/2 sec and then turns into operation.
    So there are only 3 possibilities I can see
    Bug
    Neither situation 2 or 3 are intended to work (see above) and the help is misleading
    I just don't know what I am doing (and I am willing to accept this if someone can explain it to me)
    The downside is that if situation 2 above doesn't work it does make the "call parent node" much less usefull AND it's usage/application just doesn't make sense. You cannot just drop the "call parent node" on a diagram, it only works if you have an existing VI and you perform a replace. If you can only perform situation 1 (see above) then you should just drop the "call parent node" and it picks up the correct VI as there is only 1 option. Basically if situation 2 is not intended to work then the way you apply "call parent method" doesn't make sense.
    Attachements:
    For the really keen I have included 2 zip files
    One is the "Revert Method labVIEW project" which is of course not working properly because it wants to "call parent method" on operation not operation2
    The other zip file is all pictures with a PIN for both "Revert Method" and "Extend Method" so you can see the subtle but important differences and pictrures of the relavant block diagrams including what NI suggested to me as the original fix for this problem but wasn't (they were suggesting I implement Extend Method).
     If you are wondering where I got the names, concepts and PIN diagrams from see:
    Elemental Design Patterns
    By: Jason McColm Smith
    Publisher: Addison-Wesley Professional
    Pub. Date: March 28, 2012
    Print ISBN-10: 0-321-71192-0
    Print ISBN-13: 978-0-321-71192-2
    Web ISBN-10: 0-321-71255-2
    Web ISBN-13: 978-0-321-71255-4
     All the best
    David
    Attachments:
    Call parent node fault.zip ‏356 KB
    Call parent node fault.zip ‏356 KB

    Hi tst,
    Thankyou for your reply. Can you have a look at my comments below on the points you make.
    1) Have to disagree on that one. The help is unfortunately not clear. The part you quote in your reply only indicates that the VI you are applying "Call Parent Node" to must be dynamic dispatch. There is nowhere in the help it actually states that the call parent node applies to the VI of the block diagram it is placed into. Basically case 2 in my example fulfills all that the help file requires of it. The dynamic dispatch VI's operation are part of a class that inherits from a given ancestor. Operation 2 for Reverted behaviour is a child VI that is dynamic dispatch and has the same name as the ancestor VI (operation2). The help is missing one important piece of information and should be corrected.
    2) True it does work this way. I was trying to build case 2 and had not yet built my ancestor DD for operation so the function dropped but wasn't associated with any VI. I was able to do this via a replace (obviously once the ancestor Vi was built) so this one is just bad operator
    3) Keep in mind this is an example not my end goal. I have a child implementation because this is a case where I am trying to do a "reverse override" if you like.
    3a) The point of the example is to override an objects method (operation2) with it's parent's method NOT it's own. The reason there is a child implementation with specific code is to prove that the parent method is called not the one that relates to the object (child's VI). If I start having to put case structures into the child VI I make the child VI have to determine which code to execute. The point of Revert method is to take this function out of the method that is doing the work. (Single Use Principal and encapsulation)
    3b) The VI I am calling is a Dynamic Dispatch VI. That means if I drop the superclass's VI onto the child's block diagram it will become the child's implementation. Basically I can't use Dynamic Dispatch in this case at all. It would have to be static. That then means I have to put in additional logic unless there is some way to force a VI to use a particular version of a DD VI (which I can't seem to find).
    Additional Background
    One of the uses for "Revert Method" is in versioning.
    I have a parent Version1 implementation of something and a child Version2. The child uses Version2 BUT if it fails the error trapping performs a call to Version1.
    LabVIEW has the possibility of handling the scenario but only if both Case 1 and Case 2 work. It would actually be more useful if all 3 cases worked.
    The advantage of the call parent method moving one up the tree means I don't have the track what my current object is and choose from a possible list, if, for example the hierarchy is maybe 5 levels deep. (so V4 calls V3 with a simple application of "call parent method" rather than doing additional plumbing with case structures that require care and feeding). Basically the sort of thing OOP is meant to help reduce. Anything that doesn't allow case 2 or 3 means you have to work around the limitation from a software design perspective.
    If at the end of the day Case 2 and case 3 don't and won't ever work then the help file entry needs to be fixed.
    All the best
    David

  • Central Autoreaction Method doesn't work for NW 7.10 in SolMan 7.01

    Hello!
    The central autoreaction method doesn't work for the satellite system
    NW 7.10. For systems with kernel releases 4.6D, 640, 700 this method
    works fine and e-mail alerts are coming.
    The configuration steps I've checked:
    1. Configured SCOT. The mail_send job executes every 5 minutes.
    2. Background dispatching job is released: SAP_CCMS_MONI_BATCH_DP (In
    central CEN/000/DDIC and satellite system SAT/000/DDIC)
    3. Central dispatching job is released: SAP_CCMS_CENSYS_DISPATCHER
    (Only in central system CEN/000/DDIC)
    4. The sapccm4x-agent registered as web service within CEN using
    Create Remote Monitoring for NW 7.10:
    Connection test to SAPCCM4X.<satellite_host>.00 was performed successfully
    5. Created a new autoreaction method by copying method
    CCMS_OnAlert_Email_V2 to the own Z_CCMS_Email_Alert_CEN:
    Function Module - SALO_EMAIL_IN_CASE_OF_ALERT_V2
    Execute Method on Any Server and Only in Central System, triggered by
    CCMS agents
    SENDER (EMAIL_USER) exists in CEN/000 , RECEPIENT - <distr list
    SAP_BASIS in CEN/000>, RECIPIENT-TYPEID - C
    6. Got MTE Classes from NW 7.10 satellite system and assigned this method
    Z_CCMS_Email_Alert_CEN to an MTE-class CCMS_ORAucPSAPSR3 for NW 7.10
    satellite system. The alert is red right now.
    7. The mail_send job doesn't send anything, in SCOT there are no
    sending orders.
    8. Autoreaction status on this alert in CEN in RZ20 - Sent to CEN.
    CEN_CHECKED.
    9. The alert status in RZ20 in CEN - ACTION_REQUIRED. If I execute it
    in manual the alert status changes to ACTIVE, but no email and no
    messages in sending orders in SCOT.
    Please help me to solve this issue.
    Thank you!

    Hi,
    Since you are using RECIPIENT-TYPEID =C i.e. General distribution list, pls ensure to have shared type of list created in SBWP.
    Also pls verify your SCOT configutaion , if apropriate address area i.e. *@abc.com
    Also one point to note that even if you trigger auto reaction method manually via RZ20 , pls check if alert is listed in SOST.
    if yes , that means there is problem in either SCOT configuration or distribution list.
    If alert is not appearing in SOST , that means you need to check auto reaction method parameters;
    Z_CCMS_OnAlert_Email_V2 , here check release section if Auto reaction execution method is checked.
    Regards,
    Rupali

  • Audio out port doesn't work well

    Hi, I have a Macbook Pro 13-inch, Early 2011. Since I bought it I always use my Mac whit headphones, but since a month it only works well the left headphone. I think that the problem it was my headphones but no, because I used it on my phone and workes well. So i come to the conclusion that the audio out port doesn't work well. What you think? And what you recommend to me to fix this problem?

    Probably still under warranty, but not for long. Take it to the Apple Store or AASP to have it checked ASAP.

  • IWork(Keynote, pages and numbers) doesn't work well about the issue of copy & paste problem

    I think so, too. the Keynote 6.5 is not working well on Yosemite (Mac OS X 10.10.1).
    In my case, I can't copy & paste from some program(particularly analysis program in my case) to Keynote.
    So, when I check coping & pasting the graph or image and so on to Powerpoint and other programs (one of Office is such word and 3rd programs), It works well. However It doesn't work at Keynote, page and numbers.
    Also, I tried to do the following process to solve this issue
    ======
    Something is wrong with your installation of Keynote
    Try this repair for Keynote, ensure you complete all the tasks and in the order shown:
    1  delete all the iWork applications if you have them, not just Keynote by using AppDelete.
    2  restart the Mac;   Apple menu > restart
    3  immediately after the start chime,  press the shift key until you see the Apple symbol.
             let it fully boot up,  it will take longer as the OS is repairing the drive
    4  when fully booted, go to Applications > Utilities > Disc Utility; click on the boot drive  then First Aid tab and      click  repair disc permissions
    5  when complete, restart the Mac normally
    6  install Keynote from the Mac App Store
    ====
    It doesn't work! Anything doesn't change.
    In conclusion, I didn't solve this yet!
    Plz, solve this problem or fix it!.

    This is a double posting, please only post in one discussion at a time.
    Keynote 6.5 is stable and reliable under Yosemite for most users.
    As with all new operating systems and applications, a small number of users find a few problems.
    Copy and pasting text from and into Keynote from all the applications I have, work perfectly: the applications include; Safari, Mail, Word, PowerPoint, excel, Pages, Numbers, iMovie, Photoshop, InDesign, Illustrator.
    If you want to place graphics into Keynote, use one of the following methods:
    Insert > Coose
    click the media button on an image placehoder
    click the media button on the tool bar
    drag and drop from a Finder window
    Copy and pasting images into Keynote is not supported

  • I cannot figure out how to make the text larger on an incoming email.  The finger method doesn't work and I cannot find any toolbar with which to do it.  I could find nothing in settings also.  Plese help and thank you.

    I cannot figure out how to make the text larger in a received email.  The finger method doesn't work and I can find no tool bar as I can for composing emails.  I can find nothing in settings.  Please help and thank you in advance.

    Hi there,
    Download a piece of software called TinkerTool - that might just solve your problem. I have used it myself to change the system fonts on my iMac. It is software and not an app.
    Good wishes,
    John.

  • I just downlouded the latest version of the Muse CC and it doesn't work well, it freezes all the time, in particular with the tools. Example the selection tool doesen't wor at all.

    I just downlouded the latest version of the Muse CC and it doesn't work well, it freezes all the time, in particular with the tools. Example the selection tool doesn't wor at all. Is there any solution for this problem?

    Hi!
    I restarted the computer, but the same issue happens again. When I move my mouse over some object or tool, it doesn’t come active at all (only some of the tools works) When I try to change “site properties”, I can’t choose tablet or phone mode or even I can’t select the checkboxes, only thing what I can do is change the numbers (high and width) . After all the main problem is that I can’t select some of the items or functions by mouse, but only by the keyboard.

  • The backlight of keyboard doesn't work in win7, with a well setup bootcamp drivers

    The backlight of keyboard doesn't work in win7, with a well setup bootcamp drivers

    Forum and support for Boot Camp:
    http://www.apple.com/support/bootcamp

  • Runtim exec() method not working.....giving Exception

    whts the code to use exec() method. i m using it as follows and also catching exception.
    Runtime r=Runtime.getRuntime();
    Process p=r.exec("java A");
    code is giving IOException at runtime with error=2.

    Here is an example I used when I first needed to test the runtime.exec
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    public class TestRuntime {
        public static void main(String args[])
            try
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec("java A");
                InputStream stderr = proc.getErrorStream();
                InputStreamReader isr = new InputStreamReader(stderr);
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                System.out.println("<ERROR>");
                while ( (line = br.readLine()) != null)
                    System.out.println(line);
                System.out.println("</ERROR>");
                int exitVal = proc.waitFor();
                System.out.println("Process exitValue: " + exitVal);
            } catch (Throwable t)
                t.printStackTrace();
    }Are you waiting for the process to end before exiting your program?

  • Gmail doesn't work well on my ipad, it gets hung all the time. Can you kindly help me?

    Gmail doesn't work well on my ipad, it gets hung all the time. Can you kindly help me?

    You probably want to start by updating your OS, if your information is correct and you are still running 5.1.1. You may also want to try the Gmail app. I find it works very well.

  • My Mail on my mac doesn't working well

    Why my Mail on my macbook pro doesn't working well, I couldn't see the content of my e-mail messages. how do I do? I tried to reinstall my Mail, and I couldn't fix it. Please help me

    These fixes have helped others, depending on the situation.
    Have an up-to-date Time Machine or other backup before attempting any major software updates or rebuilds.
    For more about backups:
    Time Machine Basics: http://support.apple.com/kb/ht1427
    Most commonly used backup methods: 
    https://discussions.apple.com/docs/DOC-3045
    Methodology to protect your data.  Backups vs. Archives.  Long-term data protection:
    https://discussions.apple.com/docs/DOC-6031
    Make sure your software is up to date.
    Apple > Software Update...
    A general repair to fix odd behaviors in Mail is  Mailbox > Rebuild.
    Try booting in Safe Mode.
              Boot and when you hear the bong hold down the Shift key.
              It will boot slowly.  Be patient.
              Login the the user account.
              Restart.
    Another fix:
    Shut down Mail.
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Copy and paste the following
    ~/Library/Mail/V2/MailData/
    Click Go.
    Move all "Envelope" files to your desktop.
    Restart Mail and let it convert/reindex your mailboxes.
    If this worked, Trash the Envelope files file that are on your desktop,
    if not shut down Mail and put them back.
    Another fix:
    Shut down Mail.
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Copy and paste the following:
    ~/Library/Containers/com.apple.mail/Data/Library/Caches/com.apple.mail/Cache.db
    Click Go.
    Move the Cache.db file to the Trash.
    Restart your Mac and try Mail.
    Another fix:
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Copy and paste the following
    ~/Library/Mail/V2/MailData/
    Click Go.
    Move all the Accounts.plist to your desktop.
    Restart Mail.
    If this worked, Trash the Accounts.plist file that is on your desktop,
    If not shut down Mail and put it back.
    You can try restoring mail from a Time Machine backup.
    Hold down the Option key and in the Finder Go > Library
    Enter Time Machine.
    Select a date and time from when Mail was working.
    Restore Mail.

  • I plug my iPhone 3gs into my laptop and it no longer syncs with my iTunes.  Ive tried all the trouble shooting methods and nothing works.  My iPhone doesnt appear on iTunes or under "my computer." Does anyone know how to fix this?

    I plug my iphone 3gs into my laptop and it no longer syncs with my iTunes.  I've tried all the trouble shooting methods and nothing works.  My iPhone doesn't appear on iTunes or under "My Computer." Does anyone know how to fix this?

    If AMDS is running, you are using a USB port directly on the computer and not a hub, you have disconnected other USB devices except keyboard and mouse, you have completely uninstalled and reinstalled iTunes as described in http://support.apple.com/kb/HT1925, You have tried cleaning the connector on the bottom of the phone, you have tried a different cable, you have installed the latest USB drivers for your computer, you have disabled your antivirus and firewall, you are running as an Administrator account and you have tried creating a new user on your computer and connected when logged in as that user then you have exhausted my knowledge. The only other thing to try is a different computer. If it isn't recognized on a different computer you have a hardware problem. Good luck!

  • HT1338 I'm trying to print a document fro safari and the print command is at the bottom of the page and not visible.  I can't move it up and the print command shortcut doesn't work.  How do I print this document.

    I'm trying to print a document from safari and the print command is at the bottom of the page and I can't move it up.  The print command shortcut doesn't work and I would like to know how I can print this document.

    Why do we have to install 2 add ins for something that should be built in? Please add this to the next version or an update to this one even. We should see the full path of a bookmark when we search for it. Show Parent Folder alone isn't enough if you have sub folders, so I installed Go Parent Folder as well in case of sub folders.

Maybe you are looking for

  • Search case-insensitive.

    HI All , i want to create program that use search from table but case-insensitive , How i can do that ? Regards James     SELECT agr_name UP TO iv_limit ROWS     FROM ZROLE     INTO TABLE lt_re_role     WHERE agr_name LIKE lv_search_value.

  • Knowledge management Functionality  - C4C

    Hi , I am going to work on C4C project  and this my first C4C project with Marketing Sales and  Service as part of the scope. Our Client also have knowledge management functionality as part of the legacy. My question or my concern is  that I am aware

  • Is it available a function like trim

    in abap? I want to get the length of a chararcter field but not with blanks. I just want the characters? Thank you. Deniz.

  • Save my Firefox Plug-Ins & Add-Ons for future use

    I want to save my installed Firefox Plug-Ins & Add-Ons so I can install them directly on my second PC. I mean directly, so I don't have to search for them 1 by 1 . Is there some sort of Export for these? Thx

  • How to find structural differences between two tables?

    I want to find the difference in structure between objects in two 11g databases: Here I want to identify: tables/ Views with same columns, same datatype, precision and constraints Identify if the same indexes and triggers are present. I do not want t