Runtime.getRuntime().exec()  unix shell

When I try to run commands like Runtime.getRuntime().exec("ls *")
I got null returned buffer
If I use commands like Runtime.getRuntime().exec("ls file.dat")
i got the right details
Anybody know why it happens???
Thanks

Input-output redirection, filename wild-card-expansion, metacharacter evaluation etc. are performed by the command shell.
You should try String [] {"sh","-c","ls","*"}

Similar Messages

  • Unable to run certain commands on unix using the Runtime.getRuntime().exec(

    Hi Folks,
    I am unable to get any output if I try : Runtime.getRuntime().exec("who am i")
    however for Runtime.getRuntime().exec("pwd") I am getting the present working directory path !!!
    if I give Runtime.getRuntime().exec("echo $PATH") then instead of printing the path it prints $PATH instead !!! similarly it is unable to understand any of the special unix characters such as " or ' & is assuming it to be a literal instead.
    Any idea why this is happening ?? and any solution for the same
    regards
    Anand

    I don't think that Runtime.getRuntime().exec() spawns a shell it just executes the file that is specified in the string. ecause of this you can not use commands that are built-in in the shell directly nor use special shell characters. You must spawn your own shell, try something like this:
    Runtime.getRuntime().exec("sh");I'm sure you can add some switch to sh to execute a command by I am not using unix myself so I don't know how. Someone else have to help you with that. You can allways read the man-pages.

  • PROBLEM in executing a shell command through Runtime.getRuntime().exec()

    Hi all,
    I was trying to execute the following code:
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.Statement;
    import java.sql.ResultSet;
    * Created on Mar 13, 2007
    * To change the template for this generated file go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    * @author 195092
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    public class ClassReportDeleteDaemon {
         ClassReportDeleteDaemon()
         public static void main(String[] args) throws Exception
              Connection conn = null;
              Statement stmt = null;
              ResultSet rs;
              String strQuery = null;
              String strdaysback = null;
              String delstring = null;
              int daysback;
              try
                   System.out.println("REPORT DELETION ::: FINDING DRIVER");               
                   Class.forName("oracle.jdbc.driver.OracleDriver");
              catch(Exception e)
                   System.out.println("REPORT DELETION ::: DRIVER EXCEPTION--" + e.getMessage());
                   System.out.println("REPORT DELETION ::: DRIVER NOT FOUND");
              try
                   String strUrl = "jdbc:Oracle:thin:" + args[0] + "/" + args[1] + "@" + args[2];
                   System.out.println("REPORT DELETION ::: TRYING FOR JDBC CONNECTION");
                   conn = DriverManager.getConnection(strUrl);
                   System.out.println("REPORT DELETION ::: SUCCESSFUL CONNECTION");
                   while(true)
                        System.out.println("WHILE LOOP");
                        stmt = conn.createStatement();
                        strQuery = "SELECT REP_DAYS_OLD FROM T_REPORT_DEL";
                        rs = stmt.executeQuery(strQuery);
                        while(rs.next())
                             strdaysback = rs.getString("REP_DAYS_OLD");
                             //daysback = Integer.parseInt(strdaysback);
                        System.out.print("NO of Days===>" + strdaysback);
                        delstring = "find /tmp/reports1 -name " + "\"" + "*" + "\"" + " -mtime +" + strdaysback + " -print|xargs rm -r";
                        System.out.println("DELETE STRING===>" + delstring);
                        Process proc = Runtime.getRuntime().exec(delstring);
                        //Get error stream to display error messages encountered during execution of command
                        InputStream errStream=proc.getErrorStream();
                        //Get error stream to display output messages encountered during execution of command
                        InputStream inStream = proc.getInputStream();
                        InputStreamReader strReader = new InputStreamReader(errStream);
                        BufferedReader br = new BufferedReader(strReader);
                        String strLine = null;
                        while((strLine=br.readLine())!=null)
                             System.out.println(strLine);
                   }     //end of while loop
              }     //end of try
              catch (Exception e)
                   System.out.println("REPORT DELETION ::: EXCEPTION---" + e.getMessage());
                   conn.close();
         }     //end of main
    }     //end of ClassReportDeleteDaemon
    But it is giving the error "BAD OPTION -print|xargs". The command run well in shell.
    Please help.
    Thanking u.......

    Since the pipe '|' is interpreted by the shell then you need the shell to invoke your command
            String[] command = {"sh","-c","find /tmp/reports1 -name " + "\"" + "*" + "\"" + " -mtime +" + strdaysback + " -print|xargs rm -r"};
            final Process process = Runtime.getRuntime().exec(command);
      You should also read http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html at least twice and implement the recommendation regarding stdout and stderr.
    P.S. Why are you not using Java to find and delete these files?
    Message was edited by:
    sabre150

  • Need help on changing directories with Runtime.getRuntime().exec() (shell)

    I want to create a perfect remote shell with Runtime.getRuntime(). I just can't get it to change directories. I want that if the remote user type "cd.." he changes the directory. At the moment, I can't get anything else than the "user.dir" directory.
    Is there anyway to send additionnal commands to cmd.exe after the Runtime.getRuntime().exec(). Because at the moment I'm running these commands:
    cmd[0] = "cmd.exe" ;
    cmd[1] = "/C" ;
    cmd[2] = commandString;
    After that I just wanna do stuff as if I really was at the computer and had a cmd.exe window open. I tried the output stream, I tried placing "&&" in front of the commandString(worked when I did it in cmd window), tried doing multiple Runtime.getRuntime().exec(). Starting to pull my hair out here.

    Because essentially I want this to be a remote shell.
    So I need it to accepts commands such as cd to change
    around the directory so the person can navigate the
    computer.
    I just managed to be able to do it in one command
    line. For example I would send "cd c:\downloads dir"
    to the server and it would work but I would really
    like to keep track of the working directory so the
    user wouldn't always have to change the directory.Then you don't Runtime.exec() once for each command the user types. You Runtime.exec() a shell once, and pass what the user types and the shell's responses via the in/out streams available from the Process class.

  • Runtime.getruntime().exec and text

    I have an application called Truck Scale. This application has a requirement to talk with devices such as a scale indicator, zebra printer, message boards, rf readers and okidata 395 printers. In this application, we have these devices hooked to a serial mux such as a digi and we are using the JAVA COMM API. However, we are having issues with java comm api where all the data that should be transmitted to the port is not being transmitted. We can however transmitt correctly to the port using the unix shell. I would like to forgo using the Java Comm API and execute everything that needs to send or read info for a port via the unix shell. I know I can do this using the runtime.getruntime().exec. However, my issue arises with oki395. The output that needs to be send via the port (not using lp due to overhead of the unix spooler), is formatted text. When I pass the unix command, the formatted text, and my port to the runtime enviornment via the String array, my formatted text loose all of its formatting including newlines. How can I address this issue with the runtime.getruntime().exec.

    Yes, I can send a new line the port correctly from a command line.
    Here is an example of the text file.
    CROSS PLAINS TN 37049 2549
    MATERIAL SPREAD NOT GUARNTEED.NO PERSONAL CHECKS..
    615-654-9942 TOLL FREE 877-654-9942
    Date: 07/21/2009 02:47:31
    Job No: TC1
    Q Num::
    Cust No: 37206728 Src Num::
    Sold To: CROSS PLAINS UNITED METHODIST CHURCH
    Address: 7665 HIGHWAY 25 E
    CROSS PLAINS,TN 37049
    Ord By:
    Ord No: Rate Zone:
    Location: testing changes
    This text is build using a class we created called textTicket which has each line define as a string with the appropriate newlines and tabs on eac line. As soon as this object is added to the string array and is passed to exec to execute the unix command to pipe it out to the port, the textTicket loses its formatting.

  • How to get return value from Java runtime.getRuntime.exec?

    I'm running shell commands from an Oracle db (11gr2) on aix.
    But, I would like to get a return value from a shell comand... like you get with "echo $?"
    I use a code like
    CREATE OR REPLACE JAVA SOURCE NAMED common."Host" AS
    import java.io.*;
    public class Host {
      public static int executeCommand(String command) {
        int retval=0;
        try {
            String[] finalCommand;
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          final Process pr = Runtime.getRuntime().exec(finalCommand);
          pr.waitFor();
       catch (Exception ex) {
          System.out.println(ex.getLocalizedMessage());
          retval=-1;
        return retval;
    /but I do not get a return value... because I don't know how to get return value..
    Edited by: user9158455 on 22-Sep-2010 07:33

    Hi,
    Have your tried pr.exitValue() ?
    I think you also need a finally block that destroys the subprocess
    Regards
    Peter

  • Running curl command from a java program using Runtime.getRuntime.exec

    for some reason my curl command does not run when I run it from within my java program and errors out with "https protocol not supported". This same curl command however runs fine from any directory on my red hat linux system.
    To debug the problem, I printed my curl command from the java program before calling Runtime.getRuntime.exec command and then used this o/p to run from the command line and it runs fine.
    I am not using libcurl or anything else, I am running a simple curl command as a command line utility from inside a Java program.
    Any ideas on why this might be happening?

    thanks a lot for your response. The reason why I am using curl is because I need to use certificates and keys to gain access to the internal server. So I use curl "<url> --cert <path to the certificate>" --key "<path to the key>". If you don't mid could you please tell me which version of curl you are using.
    I am using 7.15 in my system.
    Below is the code which errors out.
    public int execCurlCmd(String command)
              String s = null;
              try {
                  // run the Unix "ps -ef" command
                     Process p = Runtime.getRuntime().exec(command);
                     BufferedReader stdInput = new BufferedReader(new
                          InputStreamReader(p.getInputStream()));
                     BufferedReader stdError = new BufferedReader(new
                          InputStreamReader(p.getErrorStream()));
                     // read the output from the command
                     System.out.println("Here is the standard output of the command:\n");
                     while ((s = stdInput.readLine()) != null) {
                         System.out.println(s);
                     // read any errors from the attempted command
                     System.out.println("Here is the standard error of the command (if any):\n");
                     while ((s = stdError.readLine()) != null) {
                         System.out.println(s);
                     return(0);
                 catch (IOException e) {
                     System.out.println("exception happened - here's what I know: ");
                     e.printStackTrace();
                     return(-1);
         }

  • Runtime.getRuntime().exec and quoted strings?

    Attempting to execute a command containing a quoted string. Being very new to Java I'm guessing I'm not doing it right. Below are two code bits the first one works the second doesn't. So the question is "How do I use quoted strings in a command with .exec?"
    // this one works
    try {               
    p = Runtime.getRuntime().exec("ls -l tst.java");
    p.waitFor();
    System.out.println("Done!");
    catch(Throwable e) {                                  
    system.out.println("Errors!");
    // this one fails
    try {               
    p = Runtime.getRuntime().exec("ls -l \"tst.java\"");
    p.waitFor();
    System.out.println("Done!");
    catch(Throwable e) {                                  
    system.out.println("Errors!");

    I don't know if it is too late for the answer, but I think I know what the problem is.
    You are using exec(String) method, and passed String parameter is parsed using StringTokenizer class. This means that when you use quotes as in "file1 file2", StringTokenizer parses this as "file1 and then file2" so it is not understandable command.
    To solve the problem, do not use exec(String) method, use exec(String[])
    Using this you can send separate command and separate parameters as in following example:
    If you want to send (in Unix)
    grep "SHOW lotid" text.txt
    (using exec("grep \"SHOW lotid\" text.txt") would not work)
    Do the following
    exec(new String[]{"grep", "SHOW lotid", "text.txt"});
    This avoids parsing problem when quotes are used.
    Mehmed

  • Runtime.getRuntime().exec() error message "cannot execute"

    I'm trying to start another program written in c++ with the commands:
    p=Runtime.getRuntime().exec("nameofmyprogram");
    it works with other programs written in java, and also with ordinary unixcommands like "ls" etc. but when I try to start the c++-one I get the message: cannot execute.
    I can start the program directly from the terminal window, so it's ok.
    does anybody have any idea of what I'm doing wrong?
    ( my friend claims that it has to have a name ending with .exe, is that true?)
    grateful for advice!

    My first guess would be that the program is not on the path and Java cannot find the executable, ls on the other hand is on the path..
    I'm assuming that you are running on a unix system as you are using ls, so in this case your program does not need to end in exe, this is a windows thing. If your C++ program compiled on windows it would end in exe, but this is not the case on unix systems.
    I would suggest you try either giving the exec method ./nameofmyprogram assuming java is working in the directory your compiled c++ program. The other is to give the exact location.

  • Runtime.getRuntime().exec() does not return

    Hello,
    I am running into a case where the call to Runtime.getRuntime.exec(command) does not return. The scenario is that the main thread spawns another thread which calls the Runtime.exec(). Since the call does not return, both threads seems to be hung. The jstack output from the main thread shows
    ----------------- t@2 -----------------
    0xfeedab45 ___lwp_cond_wait + 0x15
    0xfeb4030d void os::PlatformEvent::park() + 0xa9
    0xfebadd48 void ObjectMonitor::wait(long long,bool,Thread*) + 0x26c
    0xfe770287 void ObjectSynchronizer::wait(Handle,long long,Thread*) + 0xef
    0xfe76ffbb JVM_MonitorWait + 0x20f
    0xfb20a032 * java.lang.Object.wait(long) bci:0 (Interpreted frame)
    0xfb20308d * java.lang.Thread.join(long) bci:38 line:1143 (Interpreted frame)
    0xfb20308d * java.lang.Thread.join() bci:2 line:1196 (Interpreted frame)
    0xfb20308d * DataLoader.checkThreadGroup() bci:92 line:316 (Interpreted frame)
    0xfb202f27 * DataLoader.checkTables(int) bci:1 line:336 (Interpreted frame)
    0xfb202f69 * DataLoader.runLoad(int, java.lang.String, java.lang.String, java.lang.String, com.sabre.fltsked.apm.util.FSIOHelper)
    ... more below ....
    So it is waiting for the spawned thread on a join()
    And the jstack dump for the thread that called exec() is
    ----------------- t@70 -----------------
    0xfeed7409 __lwp_park + 0x19
    0xfeed1be7 cond_wait_queue + 0x5e
    0xfeed1f64 cond_wait_common + 0x1db
    0xfeed20d2 condwait + 0x7b
    0xfeed20fd cond_wait + 0x21
    0xfeed2136 pthread_cond_wait + 0x1b
    0x9741082a soft_delete_object_cleanup + 0x57
    0x97410906 soft_delete_object + 0x5b
    0x97410953 soft_delete_all_objects_in_session + 0x2e
    0x97407b7a soft_delete_session + 0xec
    0x97407860 soft_delete_all_sessions + 0x3c
    0x97402525 finalize_common + 0x66
    0x974026ae softtoken_fini + 0x34
    0x974355f9 _fini + 0x21
    0xfefdd49a remove_hdl + 0x766
    0xfefd8be9 dlclose_core + 0xb1
    0xfefd8c1d dlclose_intn + 0x21
    0xfefd8c96 dlclose_check + 0x2a
    0xfefd8d00 dlclose + 0x38
    0x97480aeb pkcs11_slottable_delete + 0xb1
    0x9747c691 finalize_common + 0xe2
    0x9747c6e0 pkcs11_fini + 0x3e
    0x9747c3bf pkcs11_fork_child + 0x73
    0xfee628b8 postforkchild_handler + 0x2f
    0xfeeca9ec fork + 0x12e
    0xfe338029 Java_java_lang_UNIXProcess_forkAndExec + 0x395
    0xfb20a032 * java.lang.UNIXProcess.forkAndExec(byte[], byte[], int, byte[], int, byte[], boolean, java.io.FileDescriptor, java.io.FileDescriptor, java.io.FileDescriptor) bci
    :0 (Interpreted frame)
    0xfb202f69 * java.lang.UNIXProcess.<init>(byte[], byte[], int, byte[], int, byte[], boolean) bci:62 line:53 (Interpreted frame)
    0xfb20308d * java.lang.ProcessImpl.start(java.lang.String[], java.util.Map, java.lang.String, boolean) bci:182 line:65 (Interpreted frame)
    0xfb202f27 * java.lang.ProcessBuilder.start() bci:112 line:452 (Interpreted frame)
    0xfb202f27 * java.lang.Runtime.exec(java.lang.String[], java.lang.String[], java.io.File) bci:16 line:593 (Interpreted frame)
    0xfb202f27 * java.lang.Runtime.exec(java.lang.String, java.lang.String[], java.io.File) bci:69 line:431 (Interpreted frame)
    0xfb202f27 * java.lang.Runtime.exec(java.lang.String) bci:4 line:328 (Interpreted frame)
    0xfb202f27 *SQLLoad(java.lang.StringBuffer) bci:181 line:51 (Interpreted frame)
    0xfb202e61 *FSLoadThread.run() bci:84 line:54 (Interpreted frame)
    The command I am trying to exec is "sqlldr" and I do have it in my PATH variable. Why is that the call to exec does not return? Any ideas?
    This is on jdk1.6.0_17
    Thanks,
    Bijoy.

    It has definitely forked, and this is the child process. It says so. If it was the parent process it would just show Java code related to launching processes. That does not involve PKCS11. After the fork there are two identical processes with the same stack: the child process of the fork goes on to replace itself with the target command via Unix exec(), which it doesn't look like it is succeeding at. The parent process doesn't do much at all, probably just housekeeping and then a Unix wait() for Process.waitFor() to hook into.

  • Runtime.getRuntime().exec doesn't work

    I write in my program this line:
    p=Runtime.getRuntime().exec("/usr/bin/identify -verbose /tmp/cible.jpg > /tmp/cible.jpg.txt");
    But the file cible.jpg.txt is not created!
    Can you explain me?
    advance thanks!
    Best regards!!!

    It doesn't work because it is literally passing the "> /tmp..." characters as a command-line argument to the "/usr/bin/identify" program, as opposed to having the shell interpreter (which you're not invoking) interpret that to mean "redirect the output to this file".

  • Don't work Runtime.getRuntime().exec

    Hi. I've written a simple programm, but it don't work(sorry for my english:)):
    import java.io.*;
    class MsgFormat {
         static String hostname;
         static String message;
    public class jPopUp {
         public static void send(MsgFormat msg) {
              if(msg.message.length()!=0) {
                   if(msg.hostname.length()!=0) {
                        try {
                             Process proc = Runtime.getRuntime().exec("echo " + msg.message
                                                                                                                                      + " | smbclient -M " + msg.hostname);
                             } catch (java.io.IOException e) {
         public static void main(String[] args) {
              try
                   MsgFormat mess = new MsgFormat();
                   System.out.println("Enter hostname: ");
                   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                   mess.hostname = in.readLine();
                   System.out.println("Enter your message: ");
                   mess.message = in.readLine();
                   send(mess);
              catch (java.io.IOException e) {}
    }

    The exec method isn't a shell. Try with something like this:String[] exec = {"/bin/bash",
                     "-c",
                     "echo "+msg.message+" | smbclient -M "+msg.hostname};
    Process proc = Runtime.getRuntime().exec(exec);

  • Runtime.getRuntime().exec("/usr/bin/env") crashes on Solaris

    I am trying to write a Java class to read environment variables on Solaris. I have read a few posts on this forum and it appears that other people have had no trouble in doing this. I have written the following code to execute the unix 'env' command and read in the standard input stream from the output.
    // start
    Process process = Runtime.getRuntime().exec("/usr/bin/env");
    try {
    process.waitFor();
    if (process.exitValue() != 0) {
    return "Process exited with non-zero status";
    catch (InterruptedException intexc) {
    return "ERROR: "+intexc.getMessage();
    BufferedReader br1 = new BufferedReader(new InputStreamReader(process.getInputStream()));
    // blah, blah, blah, code to parse input from process
    // end
    The problem that I am having is that the class crashes whenever it is run. I have substituted 'env' for a number of other commands and these work ok which makes me suspect that there is some percularity with the 'env' program. Also, the code appears to halt on the 'exec' so it is nothing to do with the reading of input, it is the actual execution of the command that it causing the problem.
    Does anyone have any experience of using 'env' in this way under Solaris or has anyone managed to develop a similar class? Any help greatly appreciated.
    Cheers,
    Jon.

    Found a solution to this in the bug database.
    Bug ID: 4098442

  • Runtime.getRuntime().exec(x) "Command not found"?

    Hello,
    I am attempting to run the following code in my java program.
    System.out.println("<!> gunzip -c " + curZippedFilePath + " | tar xf - --directory " + curMovedUnzippedPath;
    String unzipCommand[] = {"sh gunzip -c " + curZippedFilePath + " | tar xf - --directory " + curMovedUnzippedPath};
                  Process unzipChild = Runtime.getRuntime().exec(unzipCommand);
                 However, when it is run, I get the following message.
    <!> gunzip -c /gnm/apache/htdocs/GNM_Data/1c02.tgz | tar xf - --directory /gnm/GNM_Autoupdate/databaseUpdate/dataDump/1c02
    Exception in thread "main" java.io.IOException: java.io.IOException: gunzip -c /gnm/apache/htdocs/GNM_Data/1c02.tgz | tar xf - --directory /gnm/GNM_Autoupdate/databaseUpdate/dataDump/1c02: not found
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
            at java.lang.ProcessImpl.start(ProcessImpl.java:65)
            at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
            at java.lang.Runtime.exec(Runtime.java:591)
            at java.lang.Runtime.exec(Runtime.java:464)
            at DatabaseBackUpdate.main(DatabaseBackUpdate.java:49)Why is the gunzip command not found? Also, the command works when I try it in the shell. Why doesn't it work in the Java code?

    I got it!
    I needed to use the following without passing an array to the exec() function.
    String theCommand = "tar xfz " + curZippedFilePath + " -C " + dataDumpDir;
    Process unzipChild = Runtime.getRuntime().exec(theCommand);No onto another problem : (

  • Runtime.getRuntime().exec works on windows failed on linux!

    Hi,
    I'm trying to execute a linux command from java 1.4.2 using Runtime.getRuntime().exec(). The linux command produces output and write to a file in my home dir. The command runs interactively in the shell and also run on windows.
    The command is actually a mozilla pk12util. My java code to run this pk12util works on windows, but not on linux (fedora). When I print out the command I'm trying to run in java, I can run it interactively in bash shell.
    Method below is where the problem seems to be:
    public void writeCert() {
    // Declaring variables
    System.out.println("Entering writeCert method");
    String command = null;
    certFile = new File(credFileName);
    // building the command for either Linux or Windows
    if (System.getProperty("os.name").equals("Linux")) {
    command = linuxPathPrefix + File.separator + "pk12util -o "
    + credFileName + " -n \"" + nickName + "\" -d "
    + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W "
    + pk12pw;
    System.out.println("System type is linux.");
    System.out.println("Command is: " + command);
    if (System.getProperty("os.name").indexOf("Windows") != -1) {
    // command = pk12utilLoc + File.separator + "pk12util -o
    // "+credFileName+" -n "\"+nickname+\"" -d \""+dbDirectory+"\" -K
    // "+pk12pw+" -w "+pk12pw+" -W "+pk12pw;
    command = pk12utilLoc + File.separator + "pk12util.exe -o "
    + credFileName + " -n \"" + nickName + "\" -d "
    + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W "
    + pk12pw;
    System.out.println("System type is windows.");
    System.out.println("Command is: " + command);
    // If the system is neither Linux or Windows, throw exception
    if (command == null) {
    System.out.println("command equals null");
    try {
    throw new Exception("Can't identify OS");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // Having built the command, running it with Runtime.exec
    File f = new File(credFileName);
    // setting up process, getting readers and writers
    Process extraction = null;
    BufferedOutputStream writeCred = null;
    // executing command - note -o option does not create output
    // file, or write anything to it, for Linux
    try {
    extraction = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // Dealing with the the output of the command; think -o
    // option in command should just write the credential but dealing with output anyway
    BufferedWriter CredentialOut = null;
    OutputStream line;
    try {
    CredentialOut = new BufferedWriter (
    new OutputStreamWriter(
    new FileOutputStream(credFileName)));
    catch (FileNotFoundException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // writing out the output; currently having problems because I am trying to run
    }

    My error is due to the nickname "-n <nickname" parameter error. I think the problem is having a double quotes around my nickname, but if I take out the double quotes around my nickname "Jana Test's ID" won't work either because there are spaces between the String. Error below:
    Command is: /usr/bin/pk12util -o jtest.p12 -n "Jana Test's Development ID" -d /home/jnguyen/.mozilla/firefox/zdpsq44v.default -K test123 -w test123 -W test123
    Read from standard outputStreamjava.io.PrintStream@19821f
    Read from error stream: "pk12util: find user certs from nickname failed: security library: bad database."
    null
    java.lang.NullPointerException
    at ExtractCert.writeCert(ExtractCert.java:260)
    at ExtractCert.main(ExtractCert.java:302)
    Code is:
    private String nickName = null;
    private void setNickname(String nicknameIn) {
    nickName = nicknameIn;
    // building the command for either Linux or Windows
    if (System.getProperty("os.name").equals("Linux")) {
    command = linuxPathPrefix + File.separator + "pk12util -o " + credFileName + " -n \"" + nickName + "\" -d " + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W " + pk12pw;
    System.out.println("System type is linux.");
    System.out.println("Command is: " + command);
    extraction = Runtime.getRuntime().exec(command);
    BufferedReader br = new BufferedReader(
    new
    InputStreamReader(extraction.getErrorStream()));
    PrintStream p = new PrintStream(extraction.getOutputStream());
    System.out.println("Read from standard outputStream" + p);

Maybe you are looking for

  • Airplay not connecting on Itunes 10.6.3.25 on PC despite working on Itunes 11 on Mac

    I have just went back to itunes 10.6.3.25 on my PC,as 11 kept freezing whilst trying to play songs and inport from my vast library. Now my PC wont connect to my living room speakers using my airplay device and says an unknown error has occurred. The

  • Error while renaming indexes and keys in the tables

    hi gems...good afternoon.. i am using oracle 11gr2 database. when i am trying to rename the primary key, foreign key, indexes of all the tables as per the standard, then the following error is given... ORA-00604: error occurred at recursive SQL level

  • Reprot for customer outstanding

    Dear experts i want to generate one report which contains following fields 1. invoice number 2.invoice date 3.customer name 4.total ammount 5.payment terms 6.outstanding payment please give me right solution for this

  • What is the " variant "null"" mean?

    hi,after finishing my Web Dynpro Project,I built my project in DTR,an error happened.It said as follows: 2007-8-22 19:44:25 /userOut/Development Component (com.sap.ide.eclipse.component.provider.listener.DevConfListener) [Thread[ModalContext,5,main]]

  • How to manually set print ordered metadata?

    How do you manually set the Print ordered or printed metadata for apeture versions? I have ordered prints through other sites, (Costoc, Smugmug, Mpix...), and would like to be able to manualy set this flag for the images I have printed. Is there a wa