A JAVA PROGRAM TO CONTROL SYSTEM EVENTS OF WIDOWS XP

Hello everyone.
The question is: can I develop a java program that can control system events of a windows environment? For example a program to shut down the computer, log off or open and close windows applications?
If so, how can i do that??
please help me. Your help is appreciated in advance.
thanks.
Wakariuki

Hi,
If you want to make native calls, you can use JNI (Java Native Interface).
Using JNI, you call call any C/C++ funtions.
Please visit, http://java.sun.com/docs/books/jni/ for JNI structure. To program using JNI, read the book given in the link. It is very useful for beginners.

Similar Messages

  • A JAVA PROGRAM TO CONTROL SYSTEM EVENTS OF WIDOWS environment

    Hello everyone.
    The question is: can I develop a java program that can control system events of a windows environment? For example a program to shut down the computer, log off or open and close windows applications?
    If so, how can i do that??
    please help me. Your help is appreciated in advance.
    thanks.
    Wakariuki

    Hi,
    If you want to make native calls, you can use JNI (Java Native Interface).
    Using JNI, you call call any C/C++ funtions.
    Please visit, http://java.sun.com/docs/books/jni/ for JNI structure. To program using JNI, read the book given in the link. It is very useful for beginners.

  • Execute java programs automatically when system is connected to internet

    Good Day friends...
    Iam beginner in java. Please goes through the Question and please answer.
    I need to start my java programs automatically when system(windows operating-xp/7) is connected to the internet.
    Thanks in Advance,
    Shackir

    A. You might want to learn about Windows Services. Try searching for it on the web
    B. There is no way to programmatic detect if/when the local computer is connected to the internet, at least not in Java. The best you could do would be to create a timer and to periodically try to make your connection

  • How to run java program on clients system when system strats

    hi
    I want to run java program on clients computer automatically when system boots up. plzzzzz help me .......

    You can add the call to the java program to the auto start group (under windows).
    You can't start a client program when the server starts, if that is what you mean.
    Timo

  • How to put a Java Program into the System tray

    Hi all of the forum!!
    I have a question. I want to make a monitor program but I don't know how to put the program in the system tray or just to execute the program but automatically (no manual execute), but i dont want that the program appear in a window, just start to function when i start my PC. i hope anybody help me.
    Thanks
    Best Regards
    Bucio, Francisco

    There is a plenty of similar topics here, so you can use the Search on this forum or in Google to find out.
    But shortly, you will need to use JNI or get a ready-to-use library like JNIWrapper (http://www.jniwrapper.com/winpack.jsp#tray), for example, that lets you do what you want.
    Good luck,
    EToporov

  • In java program, how do triger events according to schedule.

    I want to use java to develop a program which can triger some tasks(such as backup) at specified time defined by users. But as a new comer to
    java language, currently I don't have any ideas to implement it. Would
    any buddy give me some advises? Thank you very much for your help in advance!

    Another way to go about it would be to make a Thread that will run every minute or however much you want it to run, then get the system time and covert it to a Date. You should make an object that has the Task to run and the time and date to run it, using the Calendar class to do the Date stuff. Then when your thread runs it can check its current date and time to your Task objects and if it matches it excecutes the task.

  • Control systems in Labview?

    I'm completely new to labview and am trying to program a control
    system for an experimental actuator. I have the Labview Full System
    package (8.2) and can't seem to figure out how to input a transfer
    function in the frequency domain into a block diagram. Is this even
    possible with my package, or do I need to by another palette?
    Thanks,
    Brian

    I think you can achieve this using LabVIEw itself.
    Or try searching the forums for Control System toolkit.
    Also, there is a VI in the Analyze -->> Signal Processing -->> Frequency Domain palette.
    See to it if it can fit your requirement.
    - Partha
    LabVIEW - Wires that catch bugs!

  • How to terminate and restart a java program from a controling java program?

    I have a situation where my program needs to run exactly once each one
    hour. This is a huge program that creates a lot of threads and opens
    lot of resources. After one hour has lapsed, I want to terminate this
    program (as if Exit(0) was performed on it or as if Ctrl C was pressed
    from the command line to terminate a running program) and then run it again and so on repeat the cycle each hour. This will guarantee that
    all the resouces taken by the programs are freed or if some threads were still blocked on i/o, are indeed terminated each hour.
    The java program does not have any user interface and it is run from the
    command line.

    if you can change the program to be controlled, you could make it listen for commands on some networkport for shutting it down.
    If this is not an option you could start OS programs to kill the first program. On Unix System kill will do, but you need the process id so you'd need another os call ...
    You could do the os calls in two ways
    a) execute shell commands (search the forum on how to do that
    b) write a little C wrapper for the os call so you can call them from JNI (Java Native Interface)
    I do not know of any way do this kind of thing directly
    regards
    Spieler

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • Java and interaction with system mouse events

    I would like my Java app to be notified of all Mouse events (primarily clicks is what I am interested in) even when they occur outside the java app or when java app is not the focus. For example the user may be clicking on the File menu of Microsoft Word. I'd like to know that a mouse click occured at x,y coordinate when that happens.
    Can this be done with Java API or is there a need for native code that talks to the OS (Windows and OS X) directly, which should be called with Java Native Interface?
    I would appreciate any pointers in the right direction.

    Hi,
    I'm also trying to find a way of intercepting mouse clicks when they occur outside java components.
    The code for getting the pointer location from the desktop is:
    import java.awt.*;
    public class MouseLocation
         private MouseInfo mInfo;
         private PointerInfo pInfo;
         private Point point = new Point();
         private int buttons = 0;
         private double pointX = 0d;
         private double pointY = 0d;
         private Robot robot;
         public MouseLocation()
              try
              {     robot = new Robot();     }
              catch(Exception e)     {     }
              hasMouse();     
              pointerLocation();
         }//ends constr.
         private void hasMouse()
              buttons = mInfo.getNumberOfButtons();
              if(buttons == -1)
                   System.out.println("No mouse detected.  Program terminated.");     
                   System.exit(0);     
         }//ends hasMouse()
         private void pointerLocation()
              try
                   pInfo = mInfo.getPointerInfo();
                   point = pInfo.getLocation();
                   pointX = point.getX();
                   pointY = point.getY();
                   System.out.println("pointer is at: (" + (int)pointX + ", " + (int)pointY + ")");
                   delay();
              catch(HeadlessException he)     
                   System.out.println((he.toString()) + ".  Program terminated.");     
                   System.exit(1);
              catch(SecurityException se)     
                   System.out.println((se.toString()) + ".  Program terminated.");     
                   System.exit(1);
         }//ends pointerLocation()
         public String getPointerLocation()
         {     return (point.toString());     }//ends getPointerLocation()
         public void delay()
              try
                   robot.delay(6000);     
                   pointerLocation();
              catch(Exception e)     {     }
         }//ends delay()
         public static void main(String[] args)
              MouseLocation ml = new MouseLocation();
         }//ends
    }//ends class MouseLocation

  • Help need on System setup for java programming

    HELP BADLY NEEDED!
    I recently installed java (jdk version8 152mb) on my HP630 win7 because i want to learn java. But when practising, after using notepad to code samples like "Hello Word" and saving it with .java format, it still cannot run on my pc.
    Pls i think i need a complete and comprehensible guide on how to install and prepare my win7 laptop for java programming.
    Thanks in anticipation

    Hello,
       one suggestion is to ensure your system's environment PATH has the Java installation path included, so that it knows where to look to run Java.
     (See attached pix).
    1st) Find out where Java was installed to on your system: For example, on my Win7 PC, Java was installed to 'C:\Program Files (x86)\Java' directory.
          However, my path to the actual binaries is 'C:\Program Files (x86)\Java\jre7\bin'; this is the value I added to my system PATH.
    2nd) Check what your System's PATH has: You can do this by looking at the Environment Variables under System Properties:
       1) Search for Control Panel, then go to System & Security, then to System, then to 'Advanced System settings'.
       2) Click on 'Environment Variables...'
       3) Under the 'System variables' pane, use the scroll bar to find 'Path', and click on 'Edit...'.
       4) Here is where you add your Java path (as noted above): Note that I appended my java path to the existing Path text, taking care to separate the previous path with a semi-colon (';').
         For example, this was my existing 'Path': "C:\Program Files\CollabNet\"...and now it looks like this 'C:\Program Files\CollabNet\;C:\Program Files (x86)\Java\jre7\bin'.
       5) Click OK, OK, OK out of all those dialogs.
       Now..restart your JVM or attempt to run your Java program!.
     Good luck.
    Regards,
    HardCopy (I am employed by HP) [If this was helpful, please mark this 'Solved' or 'Accept as Solution' so others can find this too]
    How to Give Kudos | How to mark as Solved
    Attachments:
    SystemVariables.PNG ‏60 KB

  • How do I exit a java program based on condition can i use system.exit

    I have java program that is called by another program that I dont have control on. My program returns a bigdecimal... but if the ordernumber is empty in my program i dont wnat to do anything.. does system.exit work in that condition... i put it int he else if ordernumber is empty condition.. but i dont think that is the right approach..

    When software module is expected to bring some result, it should bring the result, positive or negative. I think you should check what your counterpart software expects as positive or negative result. And then implement your software this way. You can use System.exit, but this call is employed usually to indicate status with the software after it's completion and not to return any resulting value.
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#exit(int)

  • Setting persitent system environment variables using java program

    hai,
    Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
    Biju

    The solution I proposed worked only on Windows XP/2003.
    The following solution will work on Windows NT/2000/XP/2003 with JDK 1.2+.
    1- Download the [url http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip]JNIRegistry zipped archive.
    2- Open the registry-3.1.3.zip file and extract in the folder of your choice ( Eg. c:\setenv ) only the 2 first files (when sorted by path): ICE_JNIRegistry.dll and registry.jar.
    You don't need to keep the folder tree in the extraction.
    3- Create the following SetEnv.java file in the same folder ( Eg. c:\setenv ).
    import com.ice.jni.registry.Registry;
    import com.ice.jni.registry.RegistryKey;
    import com.ice.jni.registry.RegStringValue;
    import com.ice.jni.registry.RegistryValue;
    public class SetEnv
        static final String REG_HKLM_SUBKEY_NAME = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
        public static void main(String[] args)
        throws Exception
            new SetEnv().exec(args);
        void exec(String[] args)
        throws Exception
            if (args.length != 2)
                throw new IllegalArgumentException("\n\nUsage: java SetEnv {varName} {varValue}\n\n");
            String varName = args[0];
            String varValue = args[1];
            RegistryKey key = null;
            RegStringValue value;
            try
                key = Registry.HKEY_LOCAL_MACHINE.openSubKey(REG_HKLM_SUBKEY_NAME, RegistryKey.ACCESS_ALL);
                value = new RegStringValue(key, varName, RegistryValue.REG_EXPAND_SZ);           
                value.setData(varValue);
                key.setValue(value);
                key.flushKey();
            finally
                try { key.closeKey(); }
                catch (Exception e) {}
    }4- Compile it.
    javac -classpath .;registry.jar SetEnv.java
    5- Run it. varName and varValue are strings of your choice.
    java -classpath .;registry.jar -Djava.library.path=. SetEnv varName varValue

  • Running a Java Program for every shut down of system

    Hi
    I have a java program that sends an email to the Admin of my network.
    But this is program i just want to execute for every shutdown and on of my system
    Please Tell me how to execute my java program at system shutdown time and on time..
    Thanks

    Despite your objective, this is not a Java issue. The real question is "How does one run a program just before system shutdown?"
    How you execute such an application is system dependent. Java doesn't know when the system shuts down, only when the JVM shuts down. Unless you're willing to have JVM running the entire time the system is up, you'll need native code to detect system shutdown & launch the notification app.

  • 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().
    ~

Maybe you are looking for

  • Front Row, slideshow & music

    While using Front Row to play a slideshow, the same song always plays. I can't find any way to set the music to the slideshow. Can anyone help on this problem?

  • Payment Method while manually entering Receipt

    Hi, I am not getting any payment method in the LOV for Payment Method while manually entering the receipt information. Receipt class and Payment method is defined in the system. Do I need to do any other setting so that the defined Payment method wil

  • Lockbox Process, Configuration, Lockbox File format

    Hi everybody, I need a help on lockbox documents. Pls send. Regards, JC

  • Exporting Printer's Spread (PDF)

    I'm trying to figure out a way to export a file (designed as reader's spread) as printer's spread on a PDF on Indesign CS3. I'm trying to use the Inbooklet feature, but so far I can only make it print spreads, not save them as PDFs. Any suggestions?

  • Microsoft office crashes when trying to print

    Hi, upgraded my Mac from Maverick to Yosemite and now my Excel, Word, Powerpoint randomly crash when i try to print (doesnt matter if i try to print to an actual printer or make it into a pdf.). At the beginning I noticed that especially it happened