I need to convert java.lang.ProcessImpl to a String, any ideas?

Recommended Answers

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;

Jump to Post

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.

Jump to Post

All 5 Replies

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!

Be a part of the DaniWeb community

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