This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating Windows GUID from Java

 
Manish Malik
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic