Using command prompt with Java

I am trying to use command prompt within a java program and I can't figure out how to enter commands from java. I know how to start up command prompt but can someone guide me on a way to actually enter commands into the command prompt? Thanks.

The Java� Tutorial - Lesson: Basic I/O
~

Similar Messages

  • Using command prompt through java, help please!

    Hi,
    What I am trying to do is find all the processes running onthe computer using java. Normally, I would do this (without java) by opening a command prompt window, typing in tasklist and see all the running processes. I have tried to to do the same thing using java, but so far have been unsucsessful. Here is my code:
    import java.io.*;
    public class Main {
            static DataOutputStream output;
            static DataInputStream input;
            static String app="cmd.exe";
            static String command="tasklist";
            static String message="";
            public static void main(String args[])throws Exception{
            Process process = Runtime.getRuntime().exec(app);
            output=new DataOutputStream(process.getOutputStream());
            input=new DataInputStream(process.getInputStream());
            output.write(command.getBytes());
            byte[] b=new byte[input.available()];
            input.readFully(b);
            message=new String(b);
            System.out.println("Message: "+message);
            System.out.println(!message.equals(""));
            System.out.println(message!=null);
            System.out.println("Finished Program");
    }And this program prints the output (with no exceptions):
    Message:
    false
    true
    Finished Program
    I appreciate any help in fixing my program...

    DevRocks_Java wrote:
    static String app="cmd.exe";
    static String command="tasklist";
    Process process = Runtime.getRuntime().exec(app);
    output=new DataOutputStream(process.getOutputStream());
    input=new DataInputStream(process.getInputStream());What do you expect it to do? You are only telling it to open a console window, nothing more.
    if you can type tasklist at the run option, then you should be able to just substitute command in for app in your exec.

  • Delpoy EJB using command prompt, with Weblgoic 6.0

    Hi,
    I would like to know , how to deploy an EJB , from command prompt on BEA's Weblogic server 6.0.
    Thanks & Regards

    I have weblogic 5.1, but the sentence probably is equal. Try this:
    1- Open your command prompt
    2- Go to weblogic directory (ex.: c:\weblogic)
    3- Run setEnv (this put the weblogic classpath in your dos session)
    4- Run the sentence:
    java weblogic.deploy -port portNumber -host hostIP deploy <password> <ejbName> <jarName>

  • Start SQL Server Service in Remote Server using Command Prompt with Single User Mode

    Hi Folks, 
    I am able to STOP/START the Remote SQL Server Service using the following Command.
    sc \\RemoteServerName  START ServiceName 
    How to Start the Remote SQL Server Service using Single User Mode.
    sc \\RemoteServerName  START ServiceName  -m
    Narendran

    Hello,
    sqlservr.exe -m
    or
    sqlservr.exe -m -s       
    (for named instances)
    For more information:
    http://technet.microsoft.com/en-US/library/ms180965(v=SQL.105).aspx
    Configure Windows Firewall or security software properly.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How to compile & run using command prompt

    Hi all,
    I have a java application consisting of 3 packages & a jar file in the following hierarchy:
    -Project
    -classes
    -src
    -package1
    -package2
    -package3
    -file.jar
    The main class exists in package2 and uses classes within file.jar
    I want the steps to compile and execute the project using command prompt in windows such that the generated classes will be saved in the classes directory
    Can anyone help?
    Thanx in advance

    Hey,
    If your source(*.java) files are in src folder and ur currnet directory is project
    and you want all your class files to be classes folder then you can try this :
    c:\project>javac -cp src\file.jar -d classes\ src\*.javaAssuming that your file.jar file is in src folder.
    The above command will set the classpath to src\file.jar (-cp src\file.jar)
    -d classes\ - will generate all your class files with package hierarchy if any into classes directory.
    src\*.java - specifies the files to be compiled.
    Hope this helps.

  • How to print pdf file in SQL Server Reporting services report using command prompt?

    Is there a way to automatically print a SQL Server Reporting services report on command prompt? For eg: We can save a pdf file using rs.exe utility. I want to print a pdf using rs.exe utility. Is it possible? I don't want to install any 3rd party software.

    Thanks Simon for replying to my question.
    In oracle form, there is oracle command to print the report from command prompt with the help of rwrun.exe
    e.g: rwrun.exe   REPORT="D:\Test\REP_25\MLA.REP" DESNAME="testprinter" DESTYPE="PRINTER" P_FORMNAME="MLA.FMX" P_SPRACHE="E" P_SPRACHE_NR2="1" P_WHERE_BEDINGUNG="order by land_nr" USERID="test/test.world" PSV_NAME="PSV_DEMO" PSV_JOB_ID="PS$9583" RECURSIVE_LOAD="NO"
    BATCH="YES" NONBLOCKSQL="NO" ARRAYSIZE="1" PARAMFORM="NO" ERRFILE="c:\temp\psv16.tmp"<
    and to save the report we just need to change DESNAME="c:\temp\OC_100001349.pdf" DESTYPE="FILE" in above command instead of DESNAME="testprinter" DESTYPE="PRINTER".
    DESNAME and DESTYPE are the input parameters of the respective report.
    In SSRS, we can run the file from the command prompt and save it.
    rs -i "C:\Users\pujarswa\Documents\reports\new\LoadReport.rss" -s ww2004760:80/ReportServer_MSSQL -v fileName="C:\Users\pujarswa\Desktop\TipsReportLoad.pdf"
    -v reportPath="/TipsReport/LoadListTabular" -t -v format="PDF" -v LandNr=4 -u ap\swati -p test@# -e Exec2005
    But we cannot use same command for printing as you said we need to create another script for printing files.
    I have gone through the links but I dont want to use Adobe Acrobat Reader exe for printing because client it may not have Adobe Acrobat Reader on their machine.
    Also I want to pass a input parameter as type="Printer" to my report which will print directly for me and same I can acheive in command prompt passing type="Printer" fileName="C:\Users\pujarswa\Desktop\TipsReportLoad.pdf"

  • Running a Program in JDeveloper using Command Prompt

    Hi,
    I downoladed Oracle JDeveloper 10g. I had written a simple java class called Echo. java. I want to run the file using command prompt. My JDK has the following path:
    F:\Sowmya
    My java file has the following path:
    F:\Sowmya\jdev\mywork\1\1\src\pkg1
    So, in order to compile the file, I gave the following command:
    F:\Sowmya\jdk\bin>javac F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo.java
    It worked and the Echo.class file was created.
    But, when I tried to run the file using the following command,
    F:\Sowmya\jdk\bin>java F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo
    Iam getting the following error:
    Exception in thread "main" java.lang.NOClassDefFoundError: F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo
    This didnt work either:
    F:\Sowmya\jdk\bin>java F:\Sowmya\jdev\mywork\1\1\classes\pkg1\Echo
    Iam getting the same error.
    Can any one please help me regarding this.
    Thank you,
    Sowmya.

    Yes, my class contains a main. It runs if I click run in JDeveloper. But, there is no output displayed. The following is the code:
    public class Echo {
    public static void main (String[] args) {
    for (String s: args) {
    System.out.println(s);
    }

  • How to use addKeyListener in a program running using command prompt

    Does anyone have any idea how to add the addKeyListener to a program running using command prompt.
    Let me explain how the program run.
    The program is start and accept call from other program. But from time to time, I need to issue some command by pressing the keyboard, let say, ESC is closed the program, F1 is showing the stated. F2.... (This is all need to run in the command prompt windows)
    My problem is this program does not have any gui interface, so how can it be added?
    i do it this way
    public void key(){          
    addKeyListener(this);
    But it have compile error.
    mainServerImpl.java:87: cannot resolve symbol
    symbol : method addKeyListener (mainServerImpl)
    location: class mainServerImpl
    addKeyListener(this);
    I did implement KeyListener. But just don't know how to solve this error.
    can anyone tell me how to solve it or point me a source that can help.
    Thank in advance!
    Regards,
    Tai Tan

    Write your own Thread, to do this:
    public class KeyThread extends Thread {
       public void run {
          while(true) {
             int i = System.in.read();
             if(i == 123) {
                break; // to stop the thread
    // in your main:
    Thread keyThread = new KeyThread();
    keyThread.start(); // calls run() of the thread

  • Uninstalling bulk dll's from gac folder at one time using command prompt

    Hi All,
    I need to unistall bulk dll's at a time from the GAC folder using command prompt ,can any one suggest how to do this.

    Hi,
    1. Create a batch file as "Uninstall.bat".
    2. Edit this file and copy the below statements in it:
    gacutil.exe /uf DLL1
    gacutil.exe /uf DLL2
    gacutil.exe /uf DLL3
    gacutil.exe /uf DLL4
    gacutil.exe /uf DLL5
    replace DLL1 to DLL5 with your actual DLL names, which you want to uninstall.
    3. Open Visual Studio Command Prompt as Administrator.
    4. Browse to the location where you have placed the above batch file.
    5. Run the batch file.
    Hope this will help.
    HTH,
    Sumit
    Sumit Verma - MCTS BizTalk 2006/2010 - Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

  • How to run ODI scenario using command prompt

    Hi expets
    Please let me know if we can run ODI scenario using command prompt or any way other than operator.
    Regards
    Janakiram

    Go to <ODI_HOME>/oracledi/bin in command prompt and invoke startscen command with teh below parameters.
    Edited by: Guru Sankar on Feb 28, 2011 4:19 PM

  • I just updated to iTunes 11. This version will not allow me to change info on any songs. Have always use "command i" with previous versions. Anyone else experiencing this problem? A solution?

    I just updated to iTunes 11. This version will not allow me to change info on any songs. Have always use "command i" with previous versions. Anyone else experiencing this problem? A solution?

    Hey! I had the same problem you did just today when I was trying to get my second iPhone to sync. What you need to do with music or anything extra that you doing you have to creat a second playlist or picture or anything that you would like to use, so that you can add to the second device that you are going to be using. I am not sure if that will help but it helped me out a lot!! Good luck!

  • How to use MyFaces component with Java Creator 2

    Please advise for me the way to use Myfaces component with Java Creator 2. Thanks

    Apologies for the late reply, but currently what exists generally for MyFaces integration with Creator is on this blog:
    http://wiki.java.net/bin/view/Javatools/CustomComponentLibraries
    You might also want to post the same question on the nbusers alias on netbeans.org, referencing Visual Web Pack
    Regards,
    -Brad Mayer

  • Can i login to essbase console by using command prompt

    Hi All,
    Is thr any possiblity to login in to essbase console by using command prompt
    normally we login to console and will give credentails and login as same way can we do from command prompt??
    Thanks in advance
    Regards,
    SM

    Hello ,
    You can check the login through the Essbase command utility.
    go to command prompt . type - essmsh
    then you will be able to see MaxL prompt
    enter the command login username password;
    you can use this utility to load data , import export running calc etc...
    Thanks,
    KKT

  • Using command prompt for help generating

    Hi all!
    Can I use command prompt for generating webhelp instead of
    RoboHelp HTML environment?
    thank you

    See this recent post.
    Click
    here.

  • Changing java version from 4 to 5 using command prompt

    My default java version is 1.4 . I want to change to jdk 5 for a particular command prompt session alone. i used the following commands
    java - versionjava version "1.4.2_07"
    set path = C:\java\jdk150_06\bin;%path%.C:\bea92\jdk150_04\bin;C:\WINNT\system32;C:\WINNT;
    java - versionjava version "1.4.2_07"
    The version still points to 1.4. What is the method to change it from 1.4 to 1.5 ?
    Thanks..

    Rohiini wrote:
    My default java version is 1.4 . I want to change to jdk 5 for a particular command prompt session alone. i used the following commands
    java - versionjava version "1.4.2_07"No, that will say
    Unrecognized option: -try
    java -version
    set path = C:\java\jdk150_06\bin;%path%That will not set anything, try
    set path=C:\java\jdk150_06\bin;%path%or just
    path=C:\java\jdk150_06\bin;%path%

Maybe you are looking for

  • Moved G5 to new location, airport not working

    I just moved my G5 downstairs to the same exact place where I typically use my laptop (powerbook G4). Never had an issue with the laptop recognizing airport and going online, but now my G5 won't show any networks at all and I can't get airport to wor

  • .mac iWeb site with yahoo domain- much trouble

    I have 5 websites made with iweb hosted by .mac. I just got a yahoo domain name, (organizedmayhemmusic.com). I want to set that domain name to only one of my sites within iWeb, but I'm having allot of trouble. Right now I have my yahoo domain setting

  • Activity Report for Collaboration Rooms

    Hi, Is there some kind of Activity Report only for Collaboration Rooms ? Like we have Portal Activity Report for entire portal. Please give me your suggestion. Helpful answer are appriciated. Regards Prakash T

  • Sum in words for created document

    Hi Experts, I facing the critical issue which creating purchase order and getting total amount in words format its executing correctly in system default template but its not executing correcly in created Layout such as GBP : 129 One hundred twenty ni

  • Videos in Safari Stopped Working

    Hi, I updated my iphine 4 to IOS 4.3.4 today and all of a sudden I now cant view movies/mp4's through safari. I hav checked related posts and they say to check that allow plugins is on, however there is no tab for this on my settings now. Does anyone