wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 24183
    
  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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating Windows GUID from Java
 
Similar Threads
JAX-WS - wsdl with operations or message that have a long parameter list
iplanet application server - no control descriptor found
Questions about SCJP 5.0(compared to 1.4)?
how to generate a unique number
Signing a CAB file