5 Years
Discussion Span
Last Post by JamesCherrill

can you give me an example of the java.lang.ProcessImpl?

i am new to programming so the only way I can think of is to say;

String str = java.lang.ProcessImpl;


First question is why?
This class is for the exclusive use of ProcessBuilder.start() to create new processes. It's a private part of the internal technical implementation of Processes. It's definitely not a thing you should be messing about with at your level of Java expertise.

Process p = null;
pos = textArea.getCaretPosition();
String s = null;
p = Runtime.getRuntime().exec("cmd /C reg query  \"HKEY_LOCAL_MACHINE\\SOFTWARE\\AutoIt v3\\AutoIt\"");
textArea.setSelectedText( p );     
textArea.setCaretPosition( pos );
return s;

That's a snippet of my code. I'm working on an extension to jEdit which run off of Beanshell, the Java 'scripting language'. I'm trying to get the output of the Runtime line, but every method I've found eithe results in an error or the object descriptor.


I took over maintaining a project, and, this is actually the first time I've ever used Java, so everything I'm learning, I'm learning from the original author. If you guys have a better method to run a cmd command and get the output, please, let me know. I'll be more than happy to put you into the credits.


The Runtime.exec returns a Process object that describes the process. You can then use p.getInputStream() which returns the input stream connected to the normal output of the subprocess. The stream obtains data piped from the standard output of the process represented by this Process object. Once you have the input stream you can use standard Java IO classes and methods to read whatever your process writes to stdout.
Ths isn't the easiest way to learn Java, so good luck!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.