473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Linux Run time coammnd error in Java.

dmjpro
2,476 2GB
I am trying run a command in Java,which runs in console of Linux properly.
But while I am trying to run in Java then it flushes errors.
What might be the possible reasons?

The command follows..
keytool -genkey -keyalg RSA -dname "CN=DEBASISBHATTACHARYYA, OU=MS, O=IIT, C=IN" -validity 24 -alias debasis -keypass password -keystore /DATA/keystore/userkey/E84009.jks -storepass password

And the error ..what i m getting is ...
keytool error: java.lang.RuntimeException: Usage error, OU=MS, is not a legal command

Please help me.
it's urgent!
Jul 6 '08 #1
10 4629
JosAH
11,448 Expert 8TB
How did you handle those double quotes in Java?

kind regards,

Jos

ps. I fixed those bold tags for you; please preview your post before hitting submit.
Jul 6 '08 #2
dmjpro
2,476 2GB
How did you handle those double quotes in Java?

kind regards,

Jos

ps. I fixed those bold tags for you; please preview your post before hitting submit.
As it supposed to be handled ...
using \" ... :-)
Am i wrong?
One more thing ... it is running properly in windows platform.
please suggest ..it's urgent on tomorrow!
Jul 6 '08 #3
JosAH
11,448 Expert 8TB
As it supposed to be handled ...
using \" ... :-)
Am i wrong?
please suggest ..it's urgent on tomorrow!
Don't mention that it's urgent; it may be urgent to you but it isn't for me nor anyone
else. Can you show a bit of relevant code?

kind regards,

Jos
Jul 6 '08 #4
dmjpro
2,476 2GB
Don't mention that it's urgent; it may be urgent to you but it isn't for me nor anyone
else. Can you show a bit of relevant code?

kind regards,

Jos
Yeah sorry!!!

Expand|Select|Wrap|Line Numbers
  1. String command = "keytool -genkey -dname \"CN=" +
  2.                 keyStoreInfo.getCommon_name() + ", OU=" + keyStoreInfo.getOrganizational_unit() +
  3.                 ", O=" + keyStoreInfo.getOrganization() + ", C=" + keyStoreInfo.getCountry() + "\"" +
  4.                 " -alias " + keyStoreInfo.getAlias() +
  5.                 " -keypass " + keyStoreInfo.getAlias_password() + " -keystore " + keyStoreFilePath +
  6.                 " -storepass " + keyStoreInfo.getKeyStorePassword() + " -validity " + keyStoreInfo.getValidity() + 
  7.                 " -keyalg RSA";
  8.  
  9.         System.out.println("Command : " + command);
  10.         isGenerated = runCommand(command);
  11.  
This is the runCommand method....
Expand|Select|Wrap|Line Numbers
  1. boolean runCommand(String command) {
  2.         boolean isCompleted = false;
  3.  
  4.         try {
  5.             Process p = Runtime.getRuntime().exec(command);
  6.             p.waitFor();
  7.             BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
  8.             //proc=rt.exec("keytool -list -keystore keystore -storepass storepass");
  9.             BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
  10.             //proc=rt.exec("keytool -list -keystore keystore -storepass storepass");
  11.             String s = null;
  12.  
  13.             while ((s = stdInput.readLine()) != null) {
  14.                 System.out.println(s);
  15.             }
  16.             if (stdError == null) {
  17.  
  18.             } else {
  19.                 while ((s = stdError.readLine()) != null) {
  20.                     System.out.println(s);
  21.                 }
  22.  
  23.             }
  24.             isCompleted = true;
  25.         } catch (InterruptedException ex) {
  26.             isCompleted = false;
  27.             Logger.getLogger(KeyStoreGeneration.class.getName()).log(Level.SEVERE, null, ex);
  28.         } catch (IOException ex) {
  29.             isCompleted = false;
  30.             Logger.getLogger(KeyStoreGeneration.class.getName()).log(Level.SEVERE, null, ex);
  31.         }
  32.         return isCompleted;
  33.     }
  34.  
Jul 6 '08 #5
JosAH
11,448 Expert 8TB
In your runCommand() method, print out that command String and see what it is
actually trying to exec.

kind regards,

Jos
Jul 6 '08 #6
dmjpro
2,476 2GB
In your runCommand() method, print out that command String and see what it is
actually trying to exec.

kind regards,

Jos

I am simply pass the command parameter.
Is there any chance to loose characters?
Why should i check that out as we copy the printed command
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Command : " + command);
  2.  
and paste the command to console and it runs properly.
What might be the reasons?
Jul 6 '08 #7
JosAH
11,448 Expert 8TB
I am simply pass the command parameter.
Is there any chance to loose characters?
Why should i check that out as we copy the printed command
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Command : " + command);
  2.  
and paste the command to console and it runs properly.
What might be the reasons?
Just to be sure; what did it print? Was it the correct command string?

kind regards,

Jos
Jul 6 '08 #8
dmjpro
2,476 2GB
Just to be sure; what did it print? Was it the correct command string?

kind regards,

Jos
Josh I solved that problem.
Actually I read this link ...
Runtime.exec() pifalls and came to know the reality.
I used command array instead of using the whole command in a single string.
Thanks for your help Josh.
Jul 10 '08 #9
JosAH
11,448 Expert 8TB
Josh I solved that problem.
Actually I read this link ...
Runtime.exec() pifalls and came to know the reality.
I used command array instead of using the whole command in a single string.
Thanks for your help Josh.
From what I can see from your posts above you were using a single String for
your command, not an array; so what's up?

kind regards,

Jos
Jul 10 '08 #10
dmjpro
2,476 2GB
From what I can see from your posts above you were using a single String for
your command, not an array; so what's up?

kind regards,

Jos

I posted it in my 3rd post in dis thread.
Anyway now the picture runtime.exec cum to me.
Thanks for kind help!
Jul 10 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stefano Bianchi | last post by:
Ciao, I need to start a java form compiler from linux. The script that comes with the program simply says (after some checks): java -classpath Packager.jar:Filler.jar -jar EPT.jar However,...
3
by: Thomas Casanova | last post by:
Hi, I am compiling a MSVC++ project on linux gcc 3.3.4. gcc is whimsical about templates. It does understand the declaration of the template type PointerList. It scream the error :...
0
by: global | last post by:
Hi, can anyone help me I'm on Linux with UDB Runtime-Client 8.1.4 and try to connect to a windows udb-server 8.1.4 via Websphere and jdbc , and get this error: 3e1a29e5 WebGroup E...
0
by: Hemant Shah | last post by:
Folks, I have DB2 UDB 7.2 EE installed on AIX 5.2 system. I think I am at latest fixpack, see output of lslpp below. I have also installed DB2 UDB 7.2 EE on RedHat Linux 7.3 I believe that is...
1
by: srihari | last post by:
Hai, I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My machine is Intel XEON 64bit. The installation went well except for the creation of tools catalog. When I tried to install the tools...
1
by: phil campaigne | last post by:
Tom Lane wrote: > phil campaigne <pcampaigne@charter.net> writes: > > >> when I login to linux and check the env's I see: >>...
1
by: Tomek | last post by:
Welcome. I`m trying to prepere some project that shows how to use Corba technology i heterogenic systems. I`d like to create CORBA server with Borland Delphi (or C#.NET) and few client...
1
by: crabbie_upk | last post by:
Hi, Need help in tuning JAVA on LINUX. From http://www.trutek.com/index.php?id=173 I understand that on Linux operating system with 4GB memory, JVM can be run with maximum memory of 3800m. But...
5
by: ganeshp | last post by:
Hi , In Java using socket programming is it possible to have a server program on windows that services a client program on linux? I tried the code in the below given link:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.