• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get hard disk serial number using java

 
ahmed elshal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need java code that get the hard disk serial number
 
Joshua Barrett
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NOTACODEMILL
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need JNI for this, as Java doesn't provide access to this low-level information. Check out this.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not the first one who is asking this question. If you do a search, you'll find older topics about this. For example:

How to read hard disk physical serial number?

Get hard disk serial key

How to get DiskID (contains some code with a solution)

Get Serial number of exernal hard disk/Thumbdrive using java code &work for both linux and windows

Hard disk serial number
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do believe the code in that thread returns the partition serial number as assigned by Windows, not the physical hard drive serial number. This page mentions the difference:
This function returns the volume serial number that the operating system assigns when a hard disk is formatted. To programmatically obtain the hard disk's serial number that the manufacturer assigns, use the Windows Management Instrumentation (WMI) Win32_PhysicalMedia property SerialNumber.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic