Java with Windows Commands

Ok, this is a pretty tricky one. Is there a way where I can tell java to execute windows commands? I mean, I would want to develop an app that when the user quits the java app, the machine would log out the current user using code. If somebody could give me any ideas how this can be possible, I would really appreciate it. The java app is going to be run from a JScript file that is going to be loaded as the user logs on to the machine. If anyone know of any way to do this with JScript as well, I would really aprreciate it. Thanks.
Jose Bravo

Maybe this is it, I'm not to windows savy but if you know the command to execute it should work. If it is a series of commands I recomend you create a batch file:
(for java):
import java.io.*;
try {
Process p = Process.getRuntime().exec("dir");
// if you want to get the shell output //
BufferedReader = new BufferedReader(p.getInputStream());
} catch(Exception e) { }
maybe this will work,
     --Ian                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • JAVA WITH WINDOWS FORM?

    Dear all,
    I have a question about java with windows form.
    I have an exe or DLL stand alone program make by visual basic 6.
    Also I have a java software build up with swing.
    Can the exe or DLL program executed inside the Java software?
    It means I click the menu and select a function in the Java software.
    And then the exe or DLL will be executed and a windows form will be pop up.
    But I want to fake like a Java jpanel not a stand alone program run outside the Java software.
    Is it possible?
    Thanks you~~

    All here,
    You can do it ... we can hep!
    Once you choose the exe you want to run, execute it via Process ... about like so:
              String theWindowsProcess =
                                  "notepad.exe";         // OR
    //                            "runtc.bat";                // OR
    //                            "cmd /C start /min /Dc:\\temp runtc.bat";
              Process myProcess = Runtime.getRuntime().exec( theWindowsProcess);BTW ... this is a very common question.

  • Jdk conflicts with windows commands

    I'm using Windows Vista Home Premium 32bit. So i downloaded the latest jdk (6.10) and installed it. Everything went smooth so far. Then i tried compiling a little program from command prompt (javac HelloWorld.java) and i get the <'javac' is not recognized as an internal or external command, operable program or batch file.>. I searched a little and found the solution. Setting a new environment variable for the system (in both user variables and system variables: PATH with content=path to containing directory) worked just fine, all java commands work. But then i noticed that 'ping', 'ipconfig' and all other windows commands don't work <'ping' is not recognized as an internal or external command, operable program or batch file.>. When deleting the environment variables and rebooting, it's back to square one: win commands work, java commands don't.
    Is there a solution to this?
    Should i add something that points to the win commands in the PATH value? (can it be done?)

    Ok, just added c:\windows\system32 to the PATH value and it seems to work.
    Is it safe, or could i stumble across problems later on?

  • Java with Windows xp

    how to run java programmes in windows xp thru command prompt window.
    Whenever i open command prompt window i have
    c:\Documents and Settings\owner>
    I need to get access to my java folder,how do i get there thru command prompt window

    The Windows command "cd" allows you to change the current directory. In fact if you type "help" at the command line it will list all of the commands you can use there. But I strongly suggest you know how to use your operating system before you start to use it to write programs.

  • Using Java in windows command prompt

    Hi,
    I don't know if I have been searching correctly, but I haven't found a solution to my problem through common search engines.
    I'm programming in java using vim (accessed through windows command prompt), and I've created classes, everything compiles fine.
    However, I wanted to test my classes my creating instances of them (i.e. objects) through the same windows command line (command prompt). I know you can achieve this by using interaction panes through third party programs such as Dr.Java and eclipse, but I was wondering if this can be done using the command line.
    Thanks
    Jaime

    Thanks Paulcw for your quick reply! :D
    I'm guessing I didn't word my question properly.
    Neither of my classes have a main method in them, so when I am trying to create instances (objects) of them, I would like to as if my command line was the main.
    For example:
    Class1 c = new Class1(parameters);
    c.moveRight();
    etc.
    I'd like to be able to use my classes methods from the command line, I think what I'm looking for is a batch, but I'm not sure.
    Thanks again,
    Jaime

  • Interfacing Java with the command prompt

    Hi everyone,
    I'm very new to java and wanted to see if anyone had any advice before i started getting too far into this project. I want to write a java program which allows the user to draw lines on the screen, and move them around, and then the program will compute the equations of these lines and feed them into another program to study the algebra behind the geometry.
    I've written an applet which is a start towards what I want: http://math.berkeley.edu/~aboocher/Mouse2.html but I'm encountering problems since it seems very difficult to have an applet write to a file, so I started trying to just create a self-contained java program. Before I move further I was hoping someone could point me in the right direction.
    Ultimately I would like a window where the user can draw some geometric objects and the computer will write the equations to a file and then when I click "compute" say, it will run my other program (which can be done from the command line) and display "true or false"
    In case it matters, I'm on a Mac and the exterior program is called Macaulay 2.
    Thanks for your help!

    That seems highly reasonable.
    If your going to be writing to a file, it would probably be a better approach to create an application.
    As for the arithmetic part of it, you'll want to save the points that the lines dropped, to use for future calculations. Using arrays would probably be a good idea.
    You'll also want to reduce the flickering problem with your applet on the website you linked to. Maybe double buffer? Along with using arrays to recall previous lines

  • Help! Java with Windows 98??

    Hi everyone,
    I downloaded Java JDK for Windows from the Internet
    and try to compile a java program. After I use the
    notepad to edit the file, I can not open it. I got a
    message box from Windows Script Host. The message is
    that "there is no script engine for the file extension
    ".java". Is there a way that I can fix it?
    When I change the file extension to .jav. I can open it using notepad, but
    still can't compile.
    Your help is deeply appreciated!

    you probably have some weird extention mapping. You should be able to edit the .java file in notepad. You should be doing most of this in a shell (command prompt). Edit the .java file in notepad, then go to the shell and type javac filename.java, then java filename (w/no extention). I hope that helps.
    Switch to NT, easier to develop in. And try using VI instead of notepad, just suggestions.

  • Problem on Creating Unix Termial in java like windows command prompt

    hi all,
    i created an unix terminal using java swing(to connect unix server and executing commands). here i redirect the console output to textarea. The problem is i can't read the input from the textarea. and another problem is how to disable the editable option in the textarea before to the command read line. The terminal is like a putty. Any One Please give a suggestion for this problem.

    sabre150 wrote:
    georgemc wrote:
    LinaGsp wrote:
    5)then I run this command "jar cvfm MyJar.jar manifest.mf .class"If this is exactly what you did, and not a typo, that's probably your problem. Do you have a file called .class?It is more likely that the forum markup is getting in the way.Of course it is! D'oh! I seem to have a blind spot to that, I never take it into consideration...
    OP, listen to these guys, ignore this blind old fool :-(

  • Linking Java to Windows Command

    Hie all,
    I would like to call a certain executable program from windows while i am running my program. I have tried looking at classes like System, Process, and Runtime. I wonder if i had missed out anything else. Say for instance i want to "Ping" and InetAddress which i obtained from my Java socket , can anyone tells me how can i do that.
    Please help me out. Thank you so much and i am certainly waiting impatiently for a reply. Please mail your answer to me as well as posting it here. Thankz.
    Regards,
    Dave
    [email protected]

    I don't understand why you can't use Runtime.exec() to do this.
    Runtime r;
    Application app;
    InputStream is;
    r = System.getRuntime();
    try {
        app = r.exec("ping 127.0.0.1");
        is = app.getInputStream();
        // read input stream ....
    } catch (Exception e) {
        e.printStackTrace();
    }To get the results, just read the stdout from the input stream.
    Rhys

  • Button activation in Java vs windows

    first, let me say I am a novice programmer.................
    I am attempting to activate a "push button" in a java application (AWT) which is deployed on a windows 2000 environment (a commerical software package which controlls a piece of equipment). I am attepting to activate a button in this application by establishing a windows level control over the window with the push button and acivete the button with windows commands all writtin in C#.net. I wrote a routine to esstablish a focus on the window with the "push button" and am able to manually depress the space bar to activate the button, however when I try to simulate this by activating the windows "space bar" key stroke command the java button depresses but the background java application does not activate. Is there a special command sequence that JAVA recognizes to initiate an action via "spacebar" press?

    crosspost

  • Sharing iTunes with Windows 7

    Currently running OSX 10.7.5 and Windows 7, along with newest version of iTunes 11.x
    My iTunes and music files are on the Mac partition, and I wanted to be able to access my library from the Windows side. I installed iTunes and copied the iTunes library files over from my Mac side to the Windows side. I had iTunes open the library and changed preferences so that it pulls the music files from the Mac side (E:) and doesn't make any changes to the library. It works fine.
    Now, my problem is in regards to keeping the library up to date with the Mac side. If I add a song on the Mac side (and yes, I want to use this as the "master" side), I would like it to show up on the Windows side. I read a post on here from a year or so ago that described creating a .bat file that would automatically copy the Mac library files to the windows side, replacing the old library files each time Windows booted. After some reading (don't have a lot of experience with Windows Command Prompt), I was able to write a .bat file that accomplished this.
    My problem is that while it updates the files correctly, it resets my iTunes preferences such that iTunes now looks for my music files on the Windows side, and re-checks the boxes re: keeping the music library organized etc. When I manually change the preferences back, it has to update the library (I assume re-connecting all the library pointers to the actual files), but the new songs are there.
    Is there a way to keep the iTunes preferences the same so that it doesn't have to re-connect all the files every time, and it just updates with the new stuff? I assume I just don't know enough enough about how iTunes library files work, but I read somewhere that the preferences were kept in \Local Data, and not in the iTunes folder. Thanks in advance.

    If both computers are on the same wireless network, it might be most straightforward to just use Home Sharing to copy the music from the Windows PC to the MacBook Pro:
    Understanding Home Sharing
    It means having a copy of the content locally on the MBP ... but from a backup perspective, that's not such a bad thing.

  • Why windows command prompt is not working with java

    I installed java 1.6 to my computer (Laptop) and it is perfectly working with Netbeans and Eclipse
    but not working with windows xp xommand prompt
    It compiles the code but when it is going to run it throw the following exception
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Example (Unsupported major.minor version 50.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)I've reinstalled java 1.6, but the output is same
    Please help me to get it correct
    Thank you

    E:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracl
    e\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Progr
    am Files\Microsoft SQL Server\90\Tools\binn\;C:\OrCAD\OrCAD_10.0\tools\pcb\bin;C
    :\OrCAD\OrCAD_10.0\tools\specctra\bin;C:\OrCAD\OrCAD_10.0\tools\bin;C:\OrCAD\OrC
    AD_10.0\tools\PSpice\Library;C:\OrCAD\OrCAD_10.0\tools\fet\bin;C:\OrCAD\OrCAD_10
    .0\tools\jre\bin;C:\OrCAD\OrCAD_10.0\tools\Capture;C:\Program Files\QuickTime\QT
    System\;C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Microsoft Visual
    Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev9
    8\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Mic
    rosoft Visual Studio\VC98\bin;

  • Problem with Java and Windows (Mainly Vista and UAC)

    Hi all,
    I am having a problem with a program that I've devoloped. The program itself is packaged as a jar and I plan to deploy it across multiple platforms eventually however right now i am only concerned about windows based systems. I have made an installer for a windows baised systems using NSIS to install the software files. I made the installer as I need several java packages to be installed so the program would work (JAI, J3D, JAI ImageIO) and I also require the program to have fileassociations on windows.
    I know that this is not what java is about, however the majority of the users will be on windows baised systems so I've decided that OS specific installers is the best option.
    During the process I have noticed that there are several key problem with java for this type of application!
    The first issue that I have come across is getting file associations to work on java. As a .jar is not an excutable it is not possible to directly associate a filetype with it in java so to overcome this I currently run the program from a .bat files and also the program requires large memory so this also allows me to run the program with -xmx. The batch file that I use is :
    <code>
    cd PATH TO PROGRAM
    start javaw -Dsun.java2d.noddraw=true -Xmn100M -Xms500M -Xmx1000M -jar "PATH TO PROGRAM\program.jar" %1 -vram 134217728
    pause;
    </code>
    Ok so all this appears to work fine and allows windows to have file associations and start the program and thats all works perfectly but this is a non-ideal solution. Has anyone got any advice on improving this?
    The next problem that I have appears to be a problem with Vista and UAC (user access control). When a user installs the program and installs the program into the program files directory I found that the program did not work and kept saying that I did not have access to the files in the current directory. This is a problem as I read and write settings files during program execution.
    On a Vista system UAC prevents file write operations into the Program Files directory unless the program has requested elevated status even if the user is a full administrator. The probem is that there appears to be no real way to achieve this under java that I'm aware of...
    Has anyone else had this probem and has a suitable solution?
    Any advice on these issues would realy be appricated.
    Regards
    Joey

    Ok so i've kinda found a solution, its not ideal but its very good. I found this program called Elevate
    A link to the site I got it was
    http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx
    This program allows you start java with a UAC dialog for high access using
    Elevate java -jar myjar.jar
    This then allows you to have full access using java... I guess it could be dangerous but it does the job.

  • Can't run java .class programs from Windows command line!

    I have tried to get a program that I wrote with the JDK to run from the Windows command line, but it is not working. I typed:
    java HelloWorld
    Where my .class was HelloWorld.class, a compiled java program. I spelled the name correctly (and I am in the correct directory), yet I get the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
    I think something is screwy with windows, but that's just me. Any ideas??

    Likely a CLASSPATH issue - try
    java -classpath . HelloWorldGood Luck
    Lee

  • Windows command length execeeded when add java options in opmn.xml

    Hi All,
    I have a Oracle AS 9i installed on Windows 2000. There are some requirement from my application that need to add additional java-options when start up OC4J. So, I updated the opmn.xml by add my things to <data id="java-options" > for start-parameters.
    But when I start up server, I got following information in ipm.log:
    06/05/16 17:18:06 create_proc: Windows command length exceeded: D:\ora9ias\jdk\bin\javaw.exe
    I have tried Oracle AS 10g with the same OS and java-options, the server can start up without any problem.
    Is there anyway to make Oracle AS 9i work in this situation?
    Thanks for any help.

    Hi again,
    Solved the issue simply by editing the xml file with sed:
    VAR1='OC4J_I413\/config\/java2\.policy -Djava\.awt\.headless\=true -Dhttp\.webdir\.enable\=false -XX\:MaxPermSize\=128M -Xms512M -Xmx1024M -XX\:AppendRatio\=3\"\/\>'
    VAR2='OC4J_I413\/config\/java2\.policy -Djava\.awt\.headless\=true -Dhttp\.webdir\.enable\=false -XX\:MaxPermSize\=256M -Xms512M -Xmx1024M -XX\:AppendRatio\=3 -Duser\.country\=SE -Duser\.language\=sv\"\/\>'
    sed "s/$VAR1/$VAR2/" opmn.xml > Newopmn.xml; cp Newopmn.xml opmn.xml
    This is a text string that contains start parameters and it can be found here:
    <category id="start-parameters">
    <data id="java-options" value="-server -Djava.security.policy=$ORACLE_HOME/j2ee/OC4J_I413/config/java2.policy -Djava.awt.headless=true -Dhttp.webdir.enable=false -XX:MaxPermSize=128M -Xms512M -Xmx1024M -XX:AppendRatio=3"/>
    //Kerstin

Maybe you are looking for

  • Features I would like to see in z10

    1. I would like to access wifi toggle options in within the app. 2. I would like more launchers added: Customizable and acessible in ammy app - accessed by tapping or swiping on the screen. 3. The ability to put 1 active frame on top of another so th

  • How to maintian user exit for a wage type

    Hello Experts,      I would like to maintain a user exit for a particular wage type in infotype 14. As the business rules of the client are specific...So, please help me with ur views... thanks

  • Could I trade or rersell the new iPad for the the iPad with retina display

    I went back to the US to visit my dad, and I bought the new iPad Wi-Fi + cellular data 32 gb on early July. I came back to Thailand on mid July and stayed there until now. I heard that the iPad with retina display came out less than a year later afte

  • Can't add new address in 'contacts'

    Hi, As small, yet annoying problem: when I try to add a new contact to my contacts list all the text fields work fine, with one exception: filling in the address of the new contact simply doesn't work. The vertical bar fails to appear and nothing can

  • WHat is advantage of having YOSEMITE over OS 10.6?

    I have version 10.6 on my MAC. If I upgrade to YOSEMITE how does that help my MAC?