How to disable Runtime.exec method ?

i want to disable some method in java like Runtime.getRuntime().exec() and Runtime.getRuntime().totalMemory()
can i implement it by change java.policy file ,and how to do it?

You can use Set Menu Item Info with items from a runtime menu file. You don't need to insert items programmatically to use Set Menu Item Info. Use the Current VI's Menubar function to get the menubar refnum, then call Set Menu Item Info along with three inputs:
1. The menubar refnum.
2. The item tag for the item to be disabled or enabled. You may need to go back to the menu editor to get the tag, which may or may not be the same as the displayed item name.
3. A boolean wired to enabled.
I referred you to the examples just to see one part of the diagram.

Similar Messages

  • 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

  • Java's Runtime.exec() method

    When you shell out to java's Runtime.exec() method, are the process name and arguments the same for the child process that is spawned.
    We see duplicated processes about the time when our logs tell us this command was run. However, we cannot seem to reproduce this. Has anyone else seen anyone this before?

    That's what I though too. But check this out . . .
    Our code looks as follows:
    private Runtime rt;
    private Process p;
    rt = Rutime.getRuntime();
    p = rt.exec(command);
    This exec() call creates a new process, which is a child of the java process that runs this command. The final process looks like the "command" string that is passed to the exec() method call. In our case, the command is a call to the /usr/bin/mail utility to send out faxes and emails.
    We ran a very tight loop executing the rt.exec() call over and over. What we found was that for a minor fraction of a second, the newly created process looks just like the original process including the same arguments. However, the PID's indicated that one process was the child of the other. This is why it looked like we had 2 of the same processes. WILD!
    Thanks guys!

  • How to disable PUT/DELETE method in SMC tomcat

    Hi,
    SMC provides tomcat as the web server to allow logon the SMC console through IE.
    For security consideration, we have to disable the http "PUT" and "DELETE" method of tomcat. Its config file seems to be /opt/SUNWsymon/web/conf/catalina.policy, but I have no knowledge of this file.
    Do anyone know how to disable PUT/DELETE method in tomcat? Or provide me a reference book for this issue?
    Thanks a lot.

    For security consideration, we have to disable the
    http "PUT" and "DELETE" method of tomcat. Its config
    file seems to be
    /opt/SUNWsymon/web/conf/catalina.policy, but I have
    no knowledge of this file.I'm not sure how to disable that feature, but be aware if you disable the ability for Agents to send files to the SunMC web server you may break all Configuration Tasks. Agent config files are sent to the Server by HTTP to allow them to be stored as templates/snapshots.
    I don't remember seeing instructions on how to make the changes you want: the quickest way to find out is probably to call SunMC support.
    Regards,
    [email protected]

  • How to capture Runtime.exec() output? doesn't seem to work?

    This is the first time I've used Runtime.exec();
    Here's the code:
    Runtime rt = Runtime.getRuntime();
                process = rt.exec(jobCommand);
                BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String line=null;
                while((line=input.readLine()) != null) {
                     System.out.println("OUTPUT: " + line);
                int exitVal = process.waitFor();
            } catch(Exception e) {
                 e.printStackTrace();
            }//end catchas you can see, this is just copied and pasted out of the standard example for this method.
    When it gets to the line:
    while((line=input.readLine()) != null)
    it doesn't read anything. However, when i run the SAME exact command from the windows CMD prompt i get a ton of output.
    what am i doing wrong here?
    thanks.

    Welcome to the forum!
    >
    as you can see, this is just copied and pasted out of the standard example for this method.
    >
    No one can see that - you didn't post a link to the example you said you copied.
    >
    it doesn't read anything. However, when i run the SAME exact command from the windows CMD prompt i get a ton of output.
    >
    No one can see what command you are talking about; you didn't post the commnd or even describe what output you expect to get.
    >
    what am i doing wrong here?
    >
    What you are doing wrong is not providing the code you are using, the command you are using or enough information about what exactly you are doing.
    No one can try to reproduce your problem based on what you posted.

  • How to display Runtime.exec() command line output via swing

    Hi all, I'm new to java but have a pretty good understanding of it. I'm just not familiar with all the different classes. I'm having trouble capturing the output from a command I'm running from my program. I'm using Runtime.exec(cmdarray) and I'm trying to display the output/results to a JFrame. Once I get the output to display in a JFrame, I'd like it to be almost like a java command prompt where I can type into it incase the command requires user interaction.
    The command executes fine, but I just don't know how to get the results of the command when executed. The command is executed when I click a JButton, which I'd like to then open a JFrame, Popup window or something to display the command results while allowing user interaction.
    Any examples would be appreciated.
    Thank you for your help in advance and I apologize if I'm not clear.

    You can get the standard output of the program with Process.getInputStream. (It's output from the process, but input to your program.)
    This assumes of course that the program you're running is a console program that reads/writes to standard input/output.
    In fact, you really should read from standard output and standard error from the process you start, even if you're not planning to use them. Read this:
    When Runtime Exec Won't

  • Spawn a java process using runtime.exec() method

    Hi,
    This is my first post in this forum. I have a small problem. I am trying to spawn a java process using Runtime.getRuntime().exec() method in Solaris. However, there is no result in this check the follwoing program.
    /* Program Starts here */
    import java.io.*;
    public class Test {
    public static void main(String args[]) {
    String cmd[] = {"java", "-version"};
    Runtime runtime = Runtime.getRuntime();
    try{
    Process proc = runtime.exec(cmd);
    }catch(Exception ioException){
    ioException.printStackTrace();
    /* Program ends here */
    There is neither any exception nor any result.
    The result I am expecting is it should print the following:
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    Please help me out in this regard
    Thanks in advance
    Chotu.

    Yes your right. It is proc.getInputStream() or proc.getErrorStream(). That is what I get for trying to use my memory instead of looking it up. Though hopefully the OP would have seen the return type of the other methods and figured it out.

  • Problem to execute cvs command using Runtime.exec method

    Hello,
    I want execute this cvs command, with this options:
    cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d "2007/05/01<now" Project
    I tried to execute with Runtime.exec() :
    Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
    But I have an error because the smaller character is interpretate as a redirection, no as a smaller symbol.
    How I can do to use this command with Runtime.exec ?
    Thanks.
    Regards.

    Sorry,
    I had a typing mistake.
    I want say:
    Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
    Regards.

  • 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?

  • How to make Runtime.exec call Linux exec?

    Howdy,
    I am trying to use a combination of 'find' and 'rm' to delete all files with a certain extension in a directory and all of its subdirs.
    Here's the command:
    Process proc = runtime.exec("find " + dir + " -name '*.vcs' -exec rm -rf {} \\;");
    It's failing, not sure why, the exitCode is 1 instead of 0. I'm not sure if it's because I have to escape the '\' character, or if it's because I am calling Linux's 'exec' function within a Java exec() call, or something else entirely.
    The easiest thing to do would be to just use rm, but that doesn't seem to be an option. With rm it seems to be all or nothing -- If I try:
    rm -rf *.vcs
    it fails if it doesn't find a file with that extension in the start directory (even though I've specified -r). But if I enter:
    rm -rf *
    it nukes my directories AND files, something I don't want to happen. I realize this is a Linux thing, I'm just explaining it here as background, just in case.
    Anyway, so is there a way to do this? Perhaps with another system call, without using Linux's exec()?
    Many thanks
    Bob

    import java.io.*;
    public class ExecutingALinuxCommand
        static class PipeInputStreamToOutputStream implements Runnable
            PipeInputStreamToOutputStream(InputStream is, OutputStream os)
                is_ = is;
                os_ = os;
            public void run()
                try
                    byte[] buffer = new byte[1024];
                    for(int count = 0; (count = is_.read(buffer)) >= 0;)
                        os_.write(buffer, 0, count);
                catch (IOException e)
                    e.printStackTrace();
            private final InputStream is_;
            private final OutputStream os_;
        public static void main(String[] args)
            try
                String dir = System.getProperty("user.home") + "/work/dev";
                String[] command = {"sh","-c", "find " + dir + " -name '*.java' -exec grep -l Runtime {} \\;"};
                final Process process = Runtime.getRuntime().exec(command);
                new Thread(new PipeInputStreamToOutputStream(process.getInputStream(), System.out)).start();
                new Thread(new PipeInputStreamToOutputStream(process.getErrorStream(), System.err)).start();
                int returnCode = process.waitFor();
                System.out.println("Return code = " + returnCode);
            catch (Exception e)
                e.printStackTrace();
    }

  • Using Runtime exec() method to run java files and return runtime errors

    Hi
    I'm writing a java editor and I use
    Runtime.getRuntime().exec(command)
    to compile the java files. That works fine and I deal with the returned errors using the getErrorStream().
    My questions are:
    1. Can I use the same technique for returning runtime errors. In any posts I've read the process runs from begining to end, returning the errors after completion. How do I return the errors of the app as they happen interactively?
    2. If i cant use the exec and getErrorStream() methods then does anyone know how it is done?
    Thanks in advance for any help!

    Read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    MOD

  • Runtime exec methods

    looking at the Runtime API there are two methods listed namely:-
    public Process exec(String command)
                 throws IOException
        Executes the specified string command in a separate process.and
    public Process exec(String[] cmdarray)
                 throws IOException
        Executes the specified command and arguments in a separate process.
    Question:-
    Can the second method listed be used to pass in an array of different commands or not, to be executed one after the other?

    I am on window so when I do rt.exec(new String [] {"dir", "c:\\oracle});{code}
    I get the following error.
    Exception: CreateProcess: dir c:\oracle error=2                                                                                                                                                                                                                                                                                                                                       

  • Problem with Runtime.exec() method

    Hi All,
    tring _cmd = "cmd /c ";
              cmd =cmd+"sqlldr ";
              cmd = cmd + " userid=" + userId + "/" + passwd + "@"+ tnsEntry;
    cmd = cmd + " control=" + controlFilePath;
              cmd = cmd + " log=sql.log skip=1";
              System.out.println(_cmd);
         try{
                             Runtime r = Runtime.getRuntime();
                             Process process = r.exec(_cmd);
                             int exitVal = process.waitFor();
    System.out.println("Process exitValue:********** " + exitVal);
                   catch(RuntimeException re )
                        System.out.println("Failed to runtime run the process.123.."+re);
    I ve used proc.exitValue() to print the value of int value
    but i got exception
    then i used proc.waitFor() and print the value of int I got value = 4
    here it is
    Process exitValue:= 4
    could u please tell me what does it mean? how to solve if the value is 4?
    Thanks in advance

    Please don't cross-post, it is extremely rude.
    Stick with the [original thread|http://forums.sun.com/thread.jspa?threadID=5329691&tstart=0].

  • Running batch files  from Java using exec method

    Hi,
    I want to run a batch file from my Java program like this:
    try {
    Process proc = Runtime.getRuntime().exec("C:\\Refresh.bat");
    catch (Exception e) {
    MessageBox.show(e.getMessage());
    Refresh.bat file contains two commands.
    First one unzips certain zip file.
    Second one refreshes a SQL Server database using osql utility.
    Problem is that when program is run it executes only the first command and hangs on the second one.
    Please help.
    TIA
    Ravinder

    From the FAQ:
    2. How do you launch an external program on a Microsoft Windows platform from a program developed on the Java [tm] programming language?
    The following will launch notepad in Microsoft Windows NT:
    Runtime.getRuntime().exec("cmd /c notepad.exe");
    To launch a program in Microsoft Windows 95/98 use:
    Runtime.getRuntime().exec("c:\\windows\\notepad.exe");
    The Runtime class allows interaction between a program and its environment. The first string command instructs the command line interpretor, cmd to open up the calculator application.
    The exec() methods do not use a shell; any arguments must have the full pathname to the shell as well as the command itself.
    For example, to run a shell on the UNIX� platform, type:
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("/usr/bin/sh -c date");
    To run a batch file under Microsoft Windows 95/98:
    Process p = rt.exec("command.com /c c:\\mydir\\myfile.bat");
    To run a batch file under Microsoft Windows NT:
    Process p = rt.exec("cmd /c c:\\mydir\\myfile.bat");
    where 'cmd' and 'command.com' are the command-line interpreters for Microsoft Windows machines.
    The Runtime.exec() methods might not work effectively for some processes on certain platforms. Special care should be taken with native windowing, daemon, WIN16/DOS process or some shell scripts.
    regards,
    jarshe

  • Runtime.exec error on Fedora Core

    Hi,
    I have some difficulty using Runtime.exec method on Fedora Core.
    If classpath contains "space", it cannot execute a commnad.
    It works well on Windows systems with quotation marks.
    Here's my code.
    Proccess p = r.exec("java -classpath .:\"pkg root"\" A");
    Java command regards root as a class. It is actually a half of directory name. How can I solve this problem?
    thank you for reading.

    This setting works for me on Linux:
    [ebank2@giskard ivan]$ java b
    here is a - have a nice day![ebank2@giskard ivan]$ cat "a b"/a.java
    public class a {
    public static void main (String a[] ) {
    System.out.println("here is a - have a nice day!");
    }[ebank2@giskard ivan]$ cat b.java
    import java.io.*;
    public class b {
    static String s[]={ "java" , "-classpath" , "a b" , "a" };
    public static void main (String a[] ) throws Exception {
    Process p =  Runtime.getRuntime().exec(s);
    InputStream is = p.     getInputStream() ;
    int c;
    while((c=is.read()) != -1) System.out.print((char)c);
    }

Maybe you are looking for

  • Audio CD Spinning Noise

    Hi there, I recently purchased my father a mac mini to sit as a media centre under his LCD TV. All hooked up great and it all works very well... apart from audio CD's, they spin at a ridiculous speed meaning that when the sound is low all you can hea

  • Business connector scheduler gets hanged and Next run value is large number

    Hi All, I see the scheduler in business connector gets hanged and the Next run value shows huge/large number like 9223370831700598.0 sec. Please can anyone suggest what can be done. Currently BC ver is 4.7. The problem gets resolved every time when i

  • Error on extern "C" pointer argument

    Hi, I am seeing the following formal argument error, which I assume to be a compiler bug: In gmp.h there is following declaration: extern "C" void mp_get_memory_functions __GMP_PROTO ((void *(**) (size_t), void *(**) (void *, size_t, size_t), void (*

  • What's the standard program for smartform : HR_ECM_CRS

    Hi Friends what's the standard program for smartform : HR_ECM_CRS? <REMOVED BY MODERATOR> Regards, Sree Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:14 PM

  • Having probs backing up iPad after iOS5 install

    iTunes downloaded iOS5 for my iPad but after doing so, it froze upon "Backing Up." I had to 'Force Quit" iTunes. I checked the iPad and it's still running the earlier version of iTunes. I'm thinking of just deleting the new iOS5 file and using the ol