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


Win a copy of Java 8 in Action this week in the Java 8 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: 24168
    
  30

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
Signing a CAB file
iplanet application server - no control descriptor found
Questions about SCJP 5.0(compared to 1.4)?
JAX-WS - wsdl with operations or message that have a long parameter list
how to generate a unique number