Hi

I want to capture the output into java varible of one of the command line statement. The command line statement is as below:

..\_jvm\bin\java.exe -cp ..\DataLoader.jar com.salesforce.lexiloader.security.EncryptionUtil <option> <password>

Infact this is the command line utility thru which I encrypte my password, if i do manually.

But I want to use this command into my java application and want to capture the output in one variable.
Please help with some example code.

Regards,

Anzar

You can use the Runtime and Process classes in Java 6.
You will find tutorials and code on the web.

I do not understand your question. Anyway, I am nocited that
to capture the output in DOS window one may use pipe:
java ABC > data.dat
so that the output by intepreting ABC will be captured/stored in the file data.dat

Instead of using Runtime class, just include the given JAR in your application and use the relevant method of the relevant class.

package your.pkg;

import com.salesforce.lexiloader.security.EncryptionUtil;

class YourClass {
  public static void main(final String[] args) {
    byte[] encrypted = EncryptionUtil.encrypt(bytes);
  }
}

This of course assumes that there is a utility method in EncryptionUtil which takes in a sequence of bytes and encrypts them.

Hi S.O.S,

Thanks a lot. It helped me to solve my problem. Thanks a lot once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.