read registry java
How do I read a registry value and put it in my programming in Java?
Java will not be able to perform such an operation a simple way, it is not Windows specific language. You will write a DLL in Visual Basic / Visual C + +, which makes calls to Windows API to manipulate the Windows Registry (look in the Microsoft Knowledge Base for tips), and then use JNI to make calls to the DLL a Java program. Good luck! However, here are some articles that provide additional information. Http: / / / www.bayequities.com Tech / Products / http://www.gledix.com/regtoolkit commercial applications jreg_key.shtml
A month ago, wanted to know all the processes running on my machine code Java for a stupid goal. What did you do in this scenario? I tried to write code and successfully. Java can not play with system process and, consequently, the execution time is the invocation a single solution for all processes and the following:
import java.io. *; ListProcess class ( public static void main (String [] Args) throws Exception ( Runtime runtime = Runtime.getRuntime (); WSSD String [] = ( "cmd" "/ C" "Task List"); Process proc = Runtime.exec (WSSD); = Inflow proc.getInputStream InputStream (); InputStreamReader InputStreamReader = new InputStreamReader (downstream); BufferedReader in = new BufferedReader (InputStreamReader); String line; while ((line = bufferedreader.readLine ())! = null) ( System.out.println (line); ) ) )
Remember, the code is written exclusively for the Windows machine:). And a new line in the code, see a list of just a process running Java.
WSSD String [] = (cmd, "/ c", "SCA"), it is nothing but the file is executed in the locker jps.exe (jdk6 onwards).
Not all do. Writing a term code is not the real solution because there are dependencies platform. So I decided to write the code for a list of processes Java. A Again, I found the code for OpenJDK JPS (search for jps.java file:)) and I have some hints on how to do it and here it is:
import java.net .*; sun.jvmstat.monitor import .*; public class ListJavaProcess (
public static void main (String [] Args) throws Exception (
/ * Check the local machine, you can do to a remote machine and * /
Local MonitoredHost = MonitoredHost.getMonitoredHost ( "Localhost");
/ * Take all VMs running on the local host to host here * /
September VMLIST = new HashSet (local.activeVms ());
for (Object ID: VMLIST) (
/ * 1234 - Specifies the Java Virtual Machine 1234 lvmid identified by a crowd nameless.
This string becomes the absolute form / / 1234, which must be resolved against
HostIdentifier one. * /
VM MonitoredVm Local.getMonitoredVm = (new VmIdentifier ("//" + id));
/ * Take care of class file and jar file both * /
String ProcessName MonitoredVmUtil.mainClass = (VM, true);
System.out.println (id + + "------>" ProcessName);
)
) )
I wrote a lot of comments like this all together is an import from the sun instead of Java or import javax. This import resides in tools.jar, so even running simple java and javac does not work. Therefore, to run the program, go here:
E: FilesJavajdk1.6.0_10bin Program> javac – "classpath E: Program FilesJavajdk1.6.0_10libtools.jar" ListJavaProcess.java
E: Program FilesJavajdk1.6.0_10bin> java-classpath. "E: Program FilesJavajdk1.6.0_10libtools.jar" ListJavaProcess ——> ListJavaProcess 3700
Now, only a Java process is underway execution. But in the second code, you can play with some of the Java process, but the process in the native code above can not do anything but watch:)
I have no idea how to do this in JDK 1.5 or backward (running time is the direction of option). Like to learn that later.

0 Responses to “read registry java”