Running programs WINDOWS using java

Hi ,
I would appreciate if anyone could tell me how to run programs WINDOWS using JAVA language .Thank you.

I am not quite sure what you mean by that, but if you want to execute a program use:
Runtime.exec(String)

Similar Messages

  • Problem in viewing the components on running a window using java or javaw

    hi
    whenever i run a windowed application built in swing i have to resize the window in order to view the components i added to the container of the window.
    but this does not happens when i use a JProgressBar
    please help me out with this

    Read the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing tutorial. There are plenty of examples that work correctly.
    If you still have problems then post your [url http://www.physci.org/codes/sscce.jsp]Simple, Executable Demo Program that shows the incorrect behaviour. We are not going to sit here guessing what you may or may not be doing.

  • How to access a file in Unix server from windows using java

    I want to access a file in unix server from windows using java program.
    I have the following code. I am able to open the url in a web browser.
    String urlStr="ftp:user:passwd@unix-server:ftp-port//javatest/test.csv;type=i";
    URL url = new URL(urlStr);
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream)));
    String inputLine;
    while((inputLine=in.readLine()))!=null){
    System.out.println(inputLine);
    in.close();
    I get the following error
    java.io.FileNotFoundException: /javatest/test.csv
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:333)
    at java.net.URL.openStream(URL.java:960)
    at com.test.samples.Test.main(Test.java:45)

    urlStr="ftp:user:passwd@unix-server:ftp-port//javatest/test.csv;type=i";
    I have given the format of the urlStr that I am using in the code. The actiual values are used in my code. I have tried pasting this url in the browser and it opens the file.

  • Manage Windows Using Java Application

    Hi,
    I am now developing a project, where we need to track the total time working.
    Eg. If i am working with outlook in my machine in various times, at the end, it should give me the total time of working with outlook.
    For this, i need to get the Windows ID (this case outlook). How can i access OS windows using java applications.
    Any idea how to do this???

    Hello,
    Syntax for Running report as JSP is as follow. The parameters can be passed by using "+" or "&".
    http://server.com/Employee.jsp?server=sac&destype=cache&desformat=html&userid=scott/tiger@database
    Use can pass reference parameters(user parameters)while ruuning the report.
    User can use User Parameters in his reports:
    "select * from emp where hiredate = :P_1"
    User can pass this parameter to Reports(while running it as JSP)as a parameter.
    http://server.com/Employee.jsp?server=sac&destype=cache&desformat=html&userid=scott/tiger@database&P_1=17-09-2000
    With Regards
    Sachin

  • How to trace changes in directories and files in windows using java.

    Hi,
    Want to know how to trace changes in directories and files in windows using java.
    I need to create a java procedure that keeps track of any changes done in any directory and its files on a windows System and save this data.
    Edited by: shruti.ggn on Mar 20, 2009 1:56 AM

    chk out the bellow list,get the xml and make the procedure.....     
         Notes          
    1     Some of the similar software’s include HoneyBow, honeytrap, honeyC, captureHPC, honeymole, captureBAT, nepenthes.     
    2     Some of the other hacking software’s include keyloggers. Keyloggers are used for monitoring the keystrokes typed by the user so that we can get the info or passwords one is typing. Some of the keyloggers include remote monitoring capability, it means that we can send the remote file across the network to someone else and then we can monitor the key strokes of that remote pc. Some of the famous keyloggers include win-spy, real-spy, family keylogger and stealth spy.          
    3     Apart from theses tools mentioned above there are some more tools to include that are deepfreeze, Elcomsoft password cracking tools, Online DFS, StegAlyzer, Log analysis tools such as sawmill, etc.

  • Access to installed device drivers on windows using Java?

    Is it possible to get access to installed device drivers on windows using java.

    Java has APIs for accessing the OS, The OS has APIs for accessing devices.
    Java does not have APIs for direct access to devices.
    However, depending on the device, you get what you want most of the time. You would only access the device directly if the device isn't supported by the OS or Java directly.
    Which device do you have in mind?

  • Get Native Java Window using Java Access Bridge 2.0.1 & Java 1.6 and above

    I want to get the native java window (Like Java Monkey Application and Java Ferret Application) using java only, for that I tried different ways/options but unable to get the native java window and perform actions on that.
    It would be really great if you could guide me for that. I am still unable to start the Java Access Bridge.
    Please let me know the steps to get native java window using Java Access bridge and JDK 1.6.20.
    Also Note that, As per your previous suggestion, I tried to search and call initializeAccessBridge() and shutdownAccessBridge(), But unable to succeed it. I did not find such method in Accessbridge.jar.
    Please help me out.
    Best Regards

    You might want to check out this thread:
    Java Access Bridge and JRE 1.6
    If you have Java 6, you'll need to manually install Java Access Bridge 2.0.1. The JAB 2.0.2 installer for Java 6 is also available as a beta:
    http://jdk6.java.net/6uNea.html

  • Diplaying non-rectangular windows using java.

    I am seeking some information regarding rendering of irregular shaped windows using java. Would like to know if its possible to achieve that using only java, if not then which tool can be used, so that my application can be used across platforms. I have gathered some information but most of the tools are not platform independent, most are useful only for windows, there is no mention of whether the tools will be helpful in UNIX etc. environment.
    Awaiting reply,
    Shweta.

    hi,
    you can create a component you like.you must override the paint method
    and paint the component itself. the Graphics Object in paint give you some methods to paint lines,areas and colors.
    the example paint a clock :
    import java.awt.Container;
    import java.util.Calendar;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.event.WindowListener;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionEvent;
    import javax.swing.Timer;
    import java.awt.Label;
    import java.util.TimeZone;
    import java.util.SimpleTimeZone;
    public class Uhr extends java.awt.Frame implements WindowListener,ActionListener
    //{{DECLARE_CONTROLS
    Calendar cal=null;
    int sec;
    int minute;
    int hour;
    double Rh,Rm,Rs;
    int nullx,nully,mx,my,Rk;
    Timer timer=null;
    Label lab=null;
    public Uhr()
    super();
    //{{INIT_CONTROLS
    setSize(200,200);
    setLayout(null);
    setTitle("Pit-Timer");
    cal=Calendar.getInstance();
    TimeZone tz = TimeZone.getDefault();//new SimpleTimeZone(1,"GMT");//;
    // String [] tza=new String[128];
    // tza=TimeZone.getAvailableIDs();
    // for (int i=0;i<tza.length;i++)
    // System.out.println(tza);
    cal.setTimeZone(tz);
    sec=cal.get(Calendar.SECOND);//0..59
    minute=cal.get(Calendar.MINUTE); //0..59
    hour=cal.get(Calendar.HOUR_OF_DAY);//0..23
    lab=new Label("Time");
    lab.setBounds(20,170,180,25);
    add(lab);
    addWindowListener(this);
    timer=new Timer(1000,this);
    timer.setRepeats(true);
    timer.start();
    Rk=getSize().width/2;
    Rs=Rk*0.9;
    Rm=Rk*0.8;
    Rh=Rk*0.6;
    mx=getSize().width/2;
    my=getSize().height/2;
    public static void main(String[] args)
    (new Uhr()).setVisible(true);
    public void paint(Graphics gr)
    //zeichnen Hintergrund
    gr.setColor(Color.red);
    gr.fillArc(mx-Rk/2, my-Rk/2,Rk, Rk, 0, 360);
    //zeichnen Stundenskala
    gr.setColor(Color.darkGray);
    for (double alpha=0;alpha<Math.PI*2;alpha+=Math.PI/6)
    gr.drawLine( mx+(new Double (Rk/2*Math.cos(alpha))).intValue(),
    my+(new Double (Rk/2*Math.sin(alpha))).intValue(),
    mx+(new Double (Rm/2*Math.cos(alpha))).intValue(),
    my+(new Double (Rm/2*Math.sin(alpha))).intValue());
    sekunde(gr);
    minute(gr);
    stunde(gr);
    super.paint(gr);
    public void sekunde(Graphics gr)
    double alpha;
    int x,y;
    gr.setColor(Color.blue);
    alpha=(Math.PI/30*(sec-15));
    x=(new Double (Rs/2*Math.cos(alpha))).intValue();
    y=(new Double (Rs/2*Math.sin(alpha))).intValue();
    gr.drawLine(mx,my,mx+x,my+y);
    public void minute(Graphics gr)
    double alpha;
    int x,y;
    gr.setColor(Color.green);
    alpha=(Math.PI/30*(minute-15));
    x=(new Double (Rm/2*Math.cos(alpha))).intValue();
    y=(new Double (Rm/2*Math.sin(alpha))).intValue();
    gr.drawLine(mx,my,mx+x,my+y);
    public void stunde(Graphics gr)
    double alpha;
    int x,y;
    gr.setColor(Color.yellow);
    alpha=(Math.PI/6*(hour-3));
    x=(new Double (Rh/2*Math.cos(alpha))).intValue();
    y=(new Double (Rh/2*Math.sin(alpha))).intValue();
    gr.drawLine(mx,my,mx+x,my+y);
    public void actionPerformed(ActionEvent e)
    if (e.getSource()==timer)
    sec++;
    lab.setText("Time : "+new Integer(hour).toString()+":"+new Integer(minute).toString()+":"+
    new Integer(sec).toString());
    if (sec==60)
    sec=0;
    minute++;
    if (minute==60)
    minute=0;
    hour++;
    if (hour==24)
    hour=0;
    repaint();
    public void windowActivated(WindowEvent e){}
    //Invoked when a window is activated.
    public void windowClosed(WindowEvent e)
    {//Invoked when a window has been closed.
    timer.stop();
    dispose();
    System.exit(0);
    public void windowClosing(WindowEvent e)
    timer.stop();
    dispose();
    System.exit(0);}
    //Invoked when a window is in the process of being closed.
    public void windowDeactivated(WindowEvent e){}
    //Invoked when a window is de-activated.
    public void windowDeiconified(WindowEvent e){}
    //Invoked when a window is de-iconified.
    public void windowIconified(WindowEvent e){}
    //Invoked when a window is iconified.
    public void windowOpened(WindowEvent e){}
    //Invoked when a window has been opened.
    bye

  • I want run some command using java

    hi all,
    i want run command using java code.
    from cell prompt when i run this command 'mysqldump test > /home/DBNAME.sql'
    it will create DBNAME.sql file.
    but i want to run this command using java code
    i tried the following code but it did not work.
    is any other way is their?
    try {
                   Runtime.getRuntime().exec("setxkbmap nudi");
              } catch(IOException ioe) {
                   ioe.printStackTrace();
    thanks in advance
    daya

    hello,
    thanks for replay
    i am sorry the above code should be like this.(the above code is working fine)
    public class ExportTest{
         public ExportTest(){
              try {
                   Runtime.getRuntime().exec("mysqldump test > '/root/DBNAME.sql'");
              } catch(IOException ioe) {
                   ioe.printStackTrace();
              }catch(Exception e){
                   e.printStackTrace();
         public static void main(String args[]){
              new ExportTest();
    }when run above class, it not creating DBNAME.sql file.
    when run in command prompt it creating DBNAME.sql
    ($ mysqldump test > /root/DBNAME.sql)
    but i want to run this command from java code, that's way tried to do using above
    code, but it won't create DBNAME.sql
    is it wrong what i am doing? or any other way?
    thanks inadvace
    daya

  • Run shell commands using java program

    Hi guys,
    I am trying to run shell commands like cd /something and ./command with arguments as follows, but getting an exception that ./command not found.Instead of changing directory using "cd" command I am passing directory as an argument in rt,exec().
    String []cmd={"./command","arg1", "arg2", "arg3"};
    File file= new File("/path");
    try{
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd,null,file);
    proc.waitFor();
    System.out.println(proc.exitValue())
    BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    catch(Exception e)
    {e.printStackTrace();
    So can anyone please tell me what is wrong with this approach? or is there any better way to do this?
    Thanks,
    Hardik

    warnerja wrote:
    What gives you the idea that the process to execute is called "./command"? If this is in Windows, it is "cmd.exe" for example.It does not have to be cmd.exe in Windows. Any executable or .bat file can be executed as long as one either specifies the full path or the executable is in a directory that is in the PATH.
    On *nix the file has to have the executable bit set and one either specifies the full path or the executable must be in a directory that is in the PATH . If the executable is a script then if there is a hash-bang (#!) at the start of the first line then the rest of the line is taken as the interpreter  to use. For example #!/bin/bash or #!/usr/bin/perl .
    One both window and *nix one can exec() an interpreter directly and then pass the commands into the process stdin. The advantage of doing this is that one can change the environment in one line and it  remains in effect for subsequent line. A simple example of this for bash on Linux is
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    public class ExecInputThroughStdin
        public static void main(String args[]) throws Exception
            final Process process = Runtime.getRuntime().exec("bash");
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getErrorStream(), System.err)).start();
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getInputStream(), System.out)).start();
            final Writer stdin = new OutputStreamWriter(process.getOutputStream());
            stdin.write("xemacs&\n");
            stdin.write("cd ~/work\n");
            stdin.write("dir\n");
            stdin.write("ls\n");
            stdin.write("gobbldygook\n"); // Forces output to stderr
            stdin.write("echo $PATH\n");
            stdin.write("pwd\n");
            stdin.write("df -k\n");
            stdin.write("ifconfig\n");
            stdin.write("echo $CWD\n");
            stdin.write("dir\n");
            stdin.write("cd ~/work/jlib\n");
            stdin.write("dir\n");
            stdin.write("cat /etc/bash.bashrc\n");
            stdin.close();
            final int exitVal = process.waitFor();
            System.out.println("Exit value: " + exitVal);
    }One can use the same approach with Windows using cmd.exe but then one must be aware of the syntactic differences between commands running in .bat file and command run from the command line. Reading 'help cmd' s essential here.
    The class PipeInputStreamToOutputStreamRunnable in the above example just copies an InputStream to an OutputStream and I use
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class PipeInputStreamToOutputStreamRunnable implements Runnable
        public PipeInputStreamToOutputStreamRunnable(InputStream is, OutputStream os)
            is_ = is;
            os_ = os;
        public void run()
            try
                final byte[] buffer = new byte[1024];
                for (int count = 0; (count = is_.read(buffer)) >= 0;)
                    os_.write(buffer, 0, count);
            } catch (IOException e)
                e.printStackTrace();
        private final InputStream is_;
        private final OutputStream os_;
    }

  • How to reboot windows using java program?

    Hi,
    If I want to reboot the windows by Java Program,How?
    Thank you!

    what about windows server 2003?
    Runtime.getRuntime().exec("shutdown -r
    ");it will work only for windows xp

  • Running System Commands using Java

    HI,
    I am developing an application using java which requires some system commands to be run.For example i have to write a java function which can program the windows scheduler to run a particular executable at some time & another one to initiate an ftp.I however do not know how to execute the corresponding commands from java.Is there any way or some specific api(similar to the system command in c) that i can use to perform these operations.I am using j2sdk 1.4.0_01 on a win 98 machine to develop the application.

    See [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html]java.lang.Runtime

  • Unable to run my application using java web start

    i have created one application and use java web start to download the application. all the files are succesfully downloaded but when i try to run the application an expected error occur. this only happen in my machine but not in other machine i'm currently using
    -jsdk1.4.2
    -windows 2000 professional 5.00.2195 service pack 3
    -pentium III 870 Mhz
    -x86-based PC
    -RAM 256 Mhz
    Anyone knows why, plz help me with this puzzle

    Please post the information from the Web Start "Exception" and "Wrapped Exception" tabs when the error occurs (I assume the error was in fact unexpected ;-)
    A blind stab in the dark would be that you don't have write permission to the cache directory on the second machine. Also worth checking that the proxy settings on the second machine are the same as the first (if they are on the same network).

  • Running unix command using java shows error

    Hi All,
    I am trying to run UNIX move command using Java exec method but its throwing error, unable to rename. Here below is the code i am trying to run to move all files from one directory to another directory. source and destination directory exists.
    public class Demo
        public static void main(String args[])
            try
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec("mv /home/demo1/* /home/demo2");
                int exitVal = proc.waitFor();
                System.out.println("Process exitValue: " + exitVal);
            } catch (Throwable t)
                t.printStackTrace();
    }if i give "mv /home/demo1 /home/demo2" in exec method, its working, with * character its giving problem.
    Please help me in resolving the problem.
    Thank you

    Characters like *, >, &, |, etc. are interpreted by the command shell--that is by the bash, zsh, etc. programs. When you execute a command with ProcessBuilder or Runtime.exec, you're not going through one of those shells, so their interpretation of those characters is not available.
    In your code, the character * is being delivered directly to the mv command (which doesn't think * is anything special), as opposed to being turned into a list of files and directories as it would be when it's interpreted by the shell. The mv command doesn't know anything about the * character being special.
    If you want to have those shell interpretations, you need to execute the command through a shell. One example is like so, but a) you'll want to read up on the methods in exec() that take arrays of String, and b) you'll want to read up on ProcessBuilder, and c) you'll need to check your shell's man pages to see the exact syntax and arguments.
    runtime.exec("/bin/bash -c 'mv x/* y'");

  • Exception "Cannot run program" while using ProcessBuilder class

    Hi Java-Folks,
    I try to start a program within a Java application using the ProcessBuilder class. This is the first time I use ProcessBuilder so I do not have any deep knowledge of it. Here is a snippet of my code:
    static void connectToHost(String Host) {
    ProcessBuilder pb = new ProcessBuilder("connect.exe"), Host);
    Map<String, String> env = pb.environment();
    env.put("SHELLWIDTH", "64");
    pb.directory(new File("C:\\MyProgram\\ExApp\\shell"));
    try (
    Process p = pb.start();
    } catch (IOException ex) {
    Logger.getLogger(ShellUtil.class.getName()).log(Level.SEVERE, null, ex);
    }Using this method I get an IOException which says *"Cannot run program "connect.exe" (in directory "C:\MyProgram\ExApp\shell"): CreateProcess error=2, The system couldn't find the specified file"*
    Does anybody have an idea why this is not working? I tried to start another application like "notepad.exe" and that works fine. So it seems related to the fact
    that the program I want to start is only available in a certain directory and not via the PATH env-variable.
    I would appreciate any help or hint :-)
    Regards,
    Lemmy

    Okay I guess I misinterpreted the JavaDocs regarding the directory method. The exception message is a little bit confusing too, because it seems like Java tries to find the Application within the specified
    working directory.
    I tried to use the full path with the ProcessBuilder constructor and it looks like this variant is working. I still have some trouble with the application itself but I was able to start another program which is
    not in the PATH var, using the full path to the executable.
    Thanks for the help so far.
    Bye
    Lemmy

Maybe you are looking for

  • Cannot delete file Windows2Local/Components/{multiple}.settings

    Every time I shutdown JSE it shows a couple of ugly messages saying: "Cannot delete file Windows2Local/Components/classes.settings in C:\Documents and Settings\Joost\.jstudio\Ent8\config" "Cannot delete file Windows2Local/Components/sources.settings

  • InputStream in = urlconnection.getInputStream();

    Dear All, I am trying to zip a file in the client side and sending it to the server side machine......there, i am trying to unzip it and writting it over there...for this, i am using a seperate program in the client side and in the server side.......

  • Interacive report---URGENT

    Hi, I have to create an interactive report.In the basic list i want to display material,plant,stock,value/unit,open orders/deliveries/free orders(VBBE-OMENG). open orders/deliveries/free orders will be decided by the indicator VBBE-VBTYP. I have to d

  • N to 1 field mapping

    Hi Experts,      Kindly share any udf to send the multilple field value to one field N to 1 mapping. For Ex: File                                   RFC 1.Emp_Name 2.Emp_ID 3.Emp_Address        to     Employe_Details 4.Emp_contact 5.Emp_grade The five

  • Playing video of Steve Jobs' keynote from yesterday -- won't start on iMac

    I'm trying to play the video of the keynote from yesterday. When I click on it, it brings up a Quicktime window with the big Q in it. I hit the play button and nothing happens. Can someone help? Thanks. Lisa