aspose file tools*
The moose likes Java in General and the fly likes Generating Windows GUID from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generating Windows GUID from Java" Watch "Generating Windows GUID from Java" New topic
Author

Generating Windows GUID from Java

Manish Malik
Greenhorn

Joined: Jan 27, 2001
Posts: 19
Hi,

How does one generate a new Windows GUID from within Java?

I have been looking at the API available in .NET for this, and it involves a call to System.Guid.NewGuid() to get a new GUID generated. Does Java offer something similar for Windows environment?

Thanks.


Manish
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Java offers no platform-specific APIs, period; so no, there's no built-in way to do this. There are, however, two options you can pursue: first, if there's a Windows executable that generates a GUID and prints it, you could run this program using Java's java.lang.Runtime.exec() method, and capture the output.

Another option is to use the JNI, the Java Native Interface, which lets you implement the body of a Java method using native (i.e., C/C++) code.


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: Generating Windows GUID from Java