I wrote a small hack that uses Java JNA and TCP sockets to transmit battery information from a Windows 7 system to other systems on my network, and I'd now like to add thermal monitoring functionality to it. Is it possible to monitor system thermal statistics from JNA?
Edit: Forgot to mention that I need a "pure Java" solution (but JNA and friends are permitted); I'm in a horrible environment that ensures I can't run applications that aren't digitally signed, I don't have access to the digital signature list, and I can't disable the digital signature lockdowns.
Most stuff I've read shows that manufacturers use WMI to expose this information. To allow your Java program to access WMA, check out this thread: Recommended libraries/howtos for using WMI with java?
If you could find a command line utility that works on windows to get sys temp you could call it from a processbuilder in Java.
Stephane
Related
My Environment is OSX BIG SUR.
For space reasons, I need to move files from my Hard disk to a NAS (on my local network).
The current applications accessing these files (en read mode) were developed in Java.
I suppose I should use a Mount command in programs with the SMB protocol, but how to do this without be prompted for password with the SUDO command ?
So I'm looking for some examples.
You have a few ways to go:
Have java execute the smb mount command
This is a walking disaster; you don't want your java process to gain root privileges to do this.
Have java be an smb client
Possible... use JCifs-ng. The docs are lacking, and this would have been a lot simpler if it had integrated into the new files / filesystem API, but it doesn't. You'll have some coding to do.
Learn sysops
All you really need is for the OS to have that samba share mounted someplace and then, to your java process, it's all just files on a filesystem. Don't make the smb mount happen in java, ensure it's already set up before your java process even starts.
I need to find the vendor Id, Product Id of the usb drive connected to the system, through java code. Any suggestions...
I have never interfaced with USB in Java before, but have a look at JSR-80 (javax.usb) API. IBM DeveloperWorks have a tutorial (which can be useful).
If you need windows only use WMI. I do not think that cross-platform pure java solution exists at all.
You have several ways to connect to WMI. Check out Jawin, Jintegra, Jinterop. All these libraries support WMI. You can also create WMI script using VBScript or JScript and run as an external command line tool from Java using cscript command.
How to do remote file transfer between windows system using Java? In more detail, these windows systems are in same domain. I want Java API, which can transfer files (ASCII and Binary) between windows system by using assigned username, password, domain name and source and destination file location.
Use Sockets to connect (previous configuration by IP) to a SocketServer and transfer the files.
I've never done this, but I'd say you'll need to use the native Windows API to achieve this.
You could do it with JNI and C#. C# has File.Copy (see example here) that makes use of native CopyFile function.
Alternatively, take a look at this question on SO.
Hope this gives you some leads.
I need to find the vendor Id, Product Id of the usb drive connected to the system, through java code. Any suggestions...
I have never interfaced with USB in Java before, but have a look at JSR-80 (javax.usb) API. IBM DeveloperWorks have a tutorial (which can be useful).
If you need windows only use WMI. I do not think that cross-platform pure java solution exists at all.
You have several ways to connect to WMI. Check out Jawin, Jintegra, Jinterop. All these libraries support WMI. You can also create WMI script using VBScript or JScript and run as an external command line tool from Java using cscript command.
I want to create a program using Java for Automatically copied USB's data when it's insert to machine. How I do it?
There is no such thing as "USBs data", the very concept doesn't exist.
There is nothing specific in Java SE for do this job.
I may think of two ways to get that working:
Write a Java program that starts on boot (maybe a service), the prog scans continously available "drives" (D:,E:,F: ... in Windows, mount on Linux), the USB flash may be marked with a specific folder/file name (eg. COPY_USB_). That can be done with the File class.
Write a Java program that get invoked on plug-in. I know that can be done on Linux with hotplug-script support.