🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14959

Re: Reset a Windows system clock ?

#14959
From: John R. Collins
Date: Wed, 21 Jul 1999 00:00
35 lines
2044 bytes
Jason Singer <jintsjason@worldnet.att.net> wrote in message
news:7lihbc$3965@forums.borland.com...
> I nedd to be able to reset a Windows system clock direct from Java code. I
> am presently able to do it using a Runtime exec command:
>
>         Process p1 = rt.exec("tmp123.bat");
>
> where the bat file has a time command in it.
>
> I would like to be able to do from direct java statements. Can anyone
help?

The only way you are going to be able to do that is by writing a class with
a native method declared in it, running javah -jni, playing with the
resulting .h file to create a compatible .c or .cpp file that calls the
Windows service for that, compiling and building a .DLL from it, and then
doing a System.loadLibrary("MYSETTIME.DLL") in your class's static
constructor.  If you do this, make sure you put a try {} catch (Exception
ex) { ex.printStackTrace(); } around your loadLibrary call because otherwise
if it fails, which is quite likely at first or if the DLL's directory is
lost from the PATH variable, you will receive no diagnostics.  Which trust
me, is not fun.

Along the way you will have to learn JNI, debug and test your DLL, and all
sorts of other mundane things.

I would recommend staying with the .BAT file.  It has a certain economy of
labor and elegance.

When NT 5 comes out, then you may be forced to revisit the .DLL route
because that version is supposed to excise DOS completely, whatever that
means.  Not coming out till around 2001 anyway though.

John
Technical Details
Message-ID: <7n4cf3$k001@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7lihbc$3965@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9b630580e4ee913
X-Google-Attributes: gidf74b3,public
From: "John R. Collins" <johnrobertcollins@erols.com>
Subject: Re: Reset a Windows system clock ?
Date: 1999/07/21
Message-ID: <7n4cf3$k001@forums.borland.com>
X-Deja-AN: 503499194
References: <7lihbc$3965@forums.borland.com>
Organization: Another Netscape Collabra Server User
X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300
Newsgroups: borland.public.jbuilder.java.language