How to change system time from Java

Could someone tell me if there is possibility to change the system time, from within a Java program. And how to do it.

In general, no.
You could do it using JNI if you're running your JVM
with sufficient system privileges.
It seems a highly questionable thing to want to do.
Why do you have a requirement for this?
Sylvia.Now there's an idea (thread now has a 'watch'), I think I'll drop the the idea of being a hacker and learn how to write viruses instead - happy days ahead ...

Similar Messages

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • Can i change system time using java

    hi guys can i change system time using java iam doing one app in that i have to change the system time (my os is windowsXP) please tell me how to change the time

    What does this have to do with Swing?
    Well, there is no Java API that I'm aware of.
    However you can execute any Windows command by using the Runtime class. So you should be able to invoke the Time command.
    Search the Java Programming forum. There are plenty of examples on using the Runtime.exec(...) command.

  • How to change system time on Cisco MeetingPlace Express Server

    How to change system time on Cisco MeetingPlace Express Server
    Model MCS-7825-I4

    Hi Vijay,
    As per the install guide for MPX 1.x as well as 2.x "Caution! Be sure you enter the correct date and time. You must reinstall the Cisco Unified MeetingPlace Express operating system and application if you need to change the date or time of your server in the future."
    http://docwiki.cisco.com/wiki/Cisco_Unified_MeetingPlace_Express,_Release_2.x_--_Configuring_the_Cisco_Unified_MeetingPlace_Express_Server#Configuring_the_Cisco_Unified_MeetingPlace_Express_Server
    http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/meetingplace_express/1_2/english/installation/guide/iug/mpxinst3.html
    HTH
    Manish

  • How to set system time from Terminal while booted from 10.6.3 server install disk?

    I'm installing from a 10.6.3 server install disc onto a Mac Mini.  However, the battery on this Mac Mini is pretty much dead, forcing the system time back to 1/1/2001.  Through some research, this has created a problem in that I cannot move beyond the Welcome screen during setup of OS X server.  It looks like the binary has issues with the system time being older. 
    But I'm stuck in that I don't know how to adjust the system time from the Terminal Utility on the boot CD.  Can anyone help? 

    Hey, i just run in to something similar, tonight while trying to fix a computer.
    The user set the time and date on his computer to 1998 and computer locked everything including time and date in system preferences, and his user account basicly making him from administrator to guest. he could not almost any program properly that required administrator privilages.
    to fix this we used this comand in terminal " sudo date 201703162014 "    todays time and date
    20:17 03/16 2014
    we tryed everything and this fixed in 2 seconds
    ps: when you type sudo in terminal it whil give you a warning the improper use of this command is bad.... click continue.otherwhise you will not be able to execute the command.
    thanks again for this post and have a great day

  • How to run system commands from JAVA

    Hi Friends,
    How to run windows system commands from JAVA
    Runtime r=Runtime.getRuntime();
    r.exec("dir");
    Throwing following Exception
    CreateProcess :dir error=2
    Thanks in advance
    Hamsa

    Hi ,
    in Windows NT this is not possible, you can use the following :
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    java.lang.Process proc = r.exec("cmd /c dir");
    InputStream is = proc.getInputStream();
    int ch ;
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );

  • 42HL833B - How to change system time for Australia

    I have a Toshiba 42HL833B that I brought back with me to Australia from the UK.
    Everything works OK other than the system time still indicates UK time.
    Australia does not come up as a Country option in setup so I have chosen "Other".
    There does not appear to be anywhere where you can change the time.
    Is it possible to change the time manually somehow?

    I dont know if you have users manuals with you but you can download it from here .
    Maybe you can find info how to do this.

  • How to get system time from cRIO?

    Hello,
    I have an NI cRIO-9076 chassis with an NI-9467 GPS module and an NI-9234 module.
    I've downloaded the FPGA Timekeeper application which synchronises the FPGA clock to the 1PPS GPS, this works well.  What I want to do is create a trigger that at a pre-defined HH:MMS the system will start to acquire and log data from the Accelerometers connected to the NI-9234 module.
    I have added the controls for the entry of the HH:MMS and calculated the time in seconds.  I would like to compare the system clock once it is locked to the entered timestamp and then trigger.
    As I only have a value that represents seconds in the day I need to calculate the offset from EPOCH to compare against the GPS time reference.  I have read that the NI system clock runs from 01/01/1904 instead of the EPOCH 01/01/1970.
    The question is how do I get the current system time so that I can compare it against the entered time?  I only need seconds in the day = (HH * 3600) + (MM * 60) + (SS)
    Thank you,
    Kind Regards,
    Simon

    You should use the Get Date/Time in Seconds VI which will return a timestamp. You can then format this timestamp using the Format Date/Time String to give you exactly the time format that you need. Then you can extract the numbers you need and do your math.
    www.movimed.com - Custom Imaging Solutions
    Attachments:
    Get Seconds in Day.vi ‏9 KB

  • How to change system time w/o affecting iCal

    When I travel to another time zone with my laptop I would like to be able to change the system time that appears in the menu bar to the local correct time.  However, I do NOT want this to cause any changes in my calendar times.  I use Calendar only for my home appointments so do not want those to change.  Is this possible?  Thanks!

    Hey bobio,
    Thanks for the question. If I understand correctly, you want to change your time on the computer but not the time on the Calendar. I would recommend that you read this article, it may be able to help the issue.
    You can change the computer time and follow this to view Calendar events in your normal time. 
    Calendar: View all your events in a different time zone
    By default, Calendar events are displayed in your computer’s current time zone (set in Date & Time preferences). 
    Thanks for using Apple Support Communities.
    Have a good one,
    Mario

  • How to access system calls from java program?

    i am having a doubt regarding accessing system calls from a Java program like accessing unix system calls from a c program.

    Runtime.getRuntime().exec("line command here");
    example:
    Runtime.getRuntime().exec("ls -la");

  • How to execute system command from java program

    Hi all,
    I want to change directory path and then execute bash and other unix commands from a java program. When I execute them separately, it's working. Even in different try-catch block it's working but when I try to incorporate both of them in same try-catch block, I am not able to execute the commands. The change directory command works but it won't show me the effects of the bash and other commands.
    Suggestions??

    The code I am using is....
    try
    String str="cd D:\\Test";
    Process p=Runtime.getRuntime().exec("cmd /c cd
    "+str);your str string is already having cd in it but again you ar giving cd as part of this command also please check this,i will suggest you to remove cd from str
    Process p1=Runtime.getRuntime().exec("cmd /c mkdir
    "+str+"\\test_folder");you should say mkdir once you change your path,but here you are saying mkdir first and then cd D:\Test(this is because of str)..please check this
    Process p2=Runtime.getRuntime().exec("cmd /c bash");
    Process p3=Runtime.getRuntime().exec("cmd /c echo
    himanshu>name.txt");
    catch(IOException e)
    System.err.println("Error on exec() method");
    e.printStackTrace();
    Message was edited by:
    ragas

  • How can i get the System Time from the other host

    I want to get the System Time from the other host in the LAN,How can I get the Time using Java.
    Such as I am in WIN 2000 and I have a Unix host in LAN, I want to get unix host System time, How can I do it.

    Open a socket to port 13 and read a string with the time.
    -or-
    Open a socket to port 27 and read 4 bytes that are a network order timestamp
    Assuming that your UNIX machine has those services running, most do

  • HT1386 How to change fist time sync specifications (change back from icloud to outlook?

    How to change fist time sync specifications for calendar (change back from icloud to outlook?

    Go to icloud.com on your computer, sign into your iCloud account, click Calendars.  Are your events still there?  Also, what version of OS X are you running on your mac and what version of iOS are you running on your phone?

  • How to kill a system process from java code.

    Hi,
    i need to kill or remove windows system process like cmd.exe from java code.
    like removing it from end process in task mgr.
    i tried below code but its not removed.
    is there a better way we can do this.
    killing a system process from java code will create any issues?
       public static void main(String[] args) throws Exception {
       String[] cmd = { "cmd.exe" };
       Process p = Runtime.getRuntime().exec(cmd);
       p.destroy();
    any suggestions or ideas are really appreciated.
    thanks.

    Hi  jtahlborn, mohan
    yes the process is created from my java code. 
    in my code iam creating a process like below and if it is running for a long i need to kill it from java.
    For that " Runtime.getRuntime().exec("taskkill /F /PID " +  7408); " is working fine.
    7408 is my process id in taskmgr created from java and iam manually passing the PID it to kill it.
    But i need to get the PID from java code.
    Thanks for your suggestions.
    Sample Code:
    public static void main(String args[])
            try {
              Process process = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c","start"});        
              Field f = process.getClass().getDeclaredField( "handle");
              f.setAccessible( true);         
              long procHandle = f.getLong( process);
              System.out.println( "prochandle: " + procHandle );
              //Runtime.getRuntime().exec("taskkill /F /PID " +  procHandle);
            } catch( Exception e) {
              e.printStackTrace();

  • How to set iframe src from java dynammically

    Hi,
    Iam calling a servlet from jsp and servlet calls the databse query and returns the value,
    in my jsp i have ifrme, i want to change the source of iframe from java depends on the result from database , and the result must display on the iframe can any one tell me how to do this

    aurelian_cl wrote:
    I need to know how to set environment variables from java
    I want to set from java for example the environment variable "TestVar" with the value "TestValue"!1) That functionality does not belong in an application. You're trying to set environment variables, which are global across all applications, at either the user level as a whole, or across the entire machine (system level). Or, if you're only trying to set a variable active for the current process, you don't need to do that.
    2) Environment variables are not a platform-independent entity, and are thus against the nature of Java.
    My gut feel is that you are designing something in a backwards way, so my point is mainly to point that out, not to try to help you solve that particular problem.

Maybe you are looking for

  • Posting period closing

    Hi Gurus, Can any one tell me is it neccessary to close the posting period every month. Can i have th posting period for my client open for one full year. which means open and close the posting period only once a year, rather than opening and closing

  • MIGO : Error when copying batch characteristics

    Hi, I've some problem on MIGO Tcode when i want to copy the batch characteristics. I work with class type 022. I create a GR from PO. (movement 101). My item line contained sub-items (with BOM). So i would like to copy the batch characteristics in re

  • Issue with FontWeight property in Custom Control

    I have a user control which contains new FontWeight DependencyProperty as shown below. But when I set this property from XAML, it throws exception "Failed to create a 'Windows.UI.Text.FontWeight' from the text 'Normal'." It works properly if I set it

  • Turning on the flash again

    Somehow I have turned off the flash on my camera. I've searched everywhere I can think of but can't seem to find out how to switch it on again! It's a Nokia 2680 slide.

  • Can we write case statement

    Hi, Can we write CASE statement in Where clause of select statement... I searched on net, i found that case statement can be written in the having clause.. But how about in the where clause....