How to Accessibility Home windows Registry From Java

0
12
Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  


The Home windows registry is a advanced, hierarchical database that includes a multitude of entries detailing data about just about nearly anything done applying Windows. Builders at times will need to accessibility the Windows registry from inside of a Java applet or application in get to read through from the registry, publish to present keys, or insert new keys, but this can be complicated given that there is no outright perform for this process in Java.

Instead, usually third occasion computer software is essential to access the registry. One these extensively employed totally free system is identified as the JNI Registry library. This Solar permitted library can be used to obtain the Home windows registry as well as for Java courses for application progress.

The process can be to some degree intricate and is finest tried by state-of-the-art consumers commercially readily available software package to accessibility the Home windows registry from Java is significantly less complicated to use (usually basically necessitating a number of clicks of the mouse) and normally rather price tag efficient. Practically any approach to entry the Windows registry devoid of applying commercial application will require codes, hacks, and at minimum a single obtain, if not more. The adhering to is one of the more uncomplicated procedures, working with the least amount of codes and downloads, to generate entry to the Home windows registry from Java.

Stop by a highly regarded website to obtain the registry library.

Suitable click on the zip file you downloaded and decide on “Extract To,” then choose the desired area for the documents.

Double simply click the icon now on your desktop to open up the Java IDE (integrated improvement natural environment). Once the program is open, pick out “File,” then click on “New Java Class” to start out a new Java course.

You will now import the JNI registry course files into your new class. To do this, you will will need to paste a extended code into the blank course file. This code should really be enough:

import com.ice.jni.registry.Registry
import com.ice.jni.registry.RegistryException
import com.ice.jni.registry.RegistryKey
import com.ice.jni.registry.RegistryValue

Now you must increase new RegistryKey and Registry course occasions. Once that is complete, you can then open and edit the registry keys you had been searching to access in your Java application or applet. Use this code for all those needs:

Registry myRegistry = new Registry ()
Registry myRegistryKey = Registry.HKEY_Latest_User
Registry myKey = registry.openSubkey (myRegistryKey,

“Application Microsoft CurrentVersion Explorer Innovative”, RegistryKey.Obtain_ALL)
You can now get to the important value in the Home windows registry environment to be accessed or modified and then alter its value. You have to use a “consider loop” to obtain the registry when in Java simply because occasionally Java will make a registry exception in an endeavor to prevent the failure of the Java software. After managing as a result of the consider loop although in Java, you will have total registry solutions. The last code you will need to for this last move is as follows:

attempt RegsitryValue myRegistryValue = myKey.getValue (“ok”)
myKey.setValue (“Exam Price”, myRegistryValue)
myKey.deleteValue (“okay”)
capture (RegistryException reEx)

An additional routinely made use of software applied to accessibility the Windows registry can also be downloaded everywhere a copy of JWinAPI is available. This is a extra complex instrument than individuals described earlier mentioned, but is recognised to be productive.

Supply by Ryan Jennings Smith

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

LEAVE A REPLY

Please enter your comment!
Please enter your name here