How To Invoke A Command Prompt When I Run a Java Program ??

Currently I want to invoke the Command Prompt(cmd)...through a JAVA PROGRAM....
Can AnyOne tell me how to do it ???
Thanx in advance.....

hi,
to be more specific, use the following, because you mention cmd i suppose you are using Windows NT
so here goes
String cmd[] = {"cmd.exe"};
Runtime.getRuntime().exec(cmd);
cheerz
ynkrish

Similar Messages

  • I am getting an error when I run parameterized java program in Eclipse 3.1

    When I tried to compile an example, java app, I this error.
    I checked, the jre it is using is 1.5.
    Could any one you suggest how to resolve this and why this problem?
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         The type ArrayList is not generic; it cannot be parameterized with arguments <String>
         Syntax error, parameterized types are only available if source level is 5.0
         The type ArrayList is not generic; it cannot be parameterized with arguments <String>
         Syntax error, parameterized types are only available if source level is 5.0
         Type mismatch: cannot convert from int to Integer
         Incompatible operand types Integer and int
    Code:
    http://www.anyexample.com/programming/java/java_arraylist_example.xml
         at Ex01.main(Ex01.java:13)
    Edited by: xmlcrazy on Aug 23, 2009 6:59 PM

    I got it. It is under windows/preference/java/compiler/compatibility. This fixes the problem.

  • How do I create an Icon so to run my java program..

    I have a program with many different classes, thing is, I now want it as an executable file, meaning I click on one icon to run the whole program and its associated classes, I am not sure if this is where the topic should be posted but would appreciate any form of help I can get.
    Thanks.

    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • How to run a java program in command prompt

    hi i want to run a java program from in command prompt from another directory
    i want to run a file named First in C:\Program Files\Java\jdk1.6.0_07\bin
    so when i give the command
    java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    it doesnt works it shows
    C:\>java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Program Files\Java
    \jdk1/6/0_07\bin\First
    Caused by: java.lang.ClassNotFoundException: C:\Program Files\Java\jdk1.6.0_07\b
    in\First
    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)
    Could not find the main class: C:\Program Files\Java\jdk1.6.0_07\bin\First. Pro
    gram will exit.

    but it prints
    C:\>java -cp "C:\Program Files\Java\jdk1.6.0_07\bin\" First
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image
    C:\>

  • HT1338 my mac is running 10.5.8, I bought a new Nano, itunes is prompting me to get the current itunes, but my mac will not take it, states I need 10.6.8.  How do I get that?  When I run a software update, system says there is none.  Help

    my mac is running 10.5.8, I bought a new Nano, itunes is prompting me to get the current itunes, but my mac will not take it, states I need 10.6.8.  How do I get that?  When I run a software update, system says there is none.  Help

    Click here, check that your computer meets the requirements, buy and install the DVD, and then run Software Update.
    (73181)

  • How to execute a Command Prompt command from J2SE code executing on Windows

    How to execute a Command Prompt command from J2SE code executing on Windows??
    Please help me

    [http://java.sun.com/docs/books/tutorial/getStarted/]
    ~

  • Is it possible to run a java program without using the command prompt?

    Hi,
    I was wondering whether it is possible to run a Java program (not an applet) without using a command line in the command prompt?
    Basically I want to run a program that will be continually running in the background and hence I don't want to have a command prompt screen loaded up as well - I just want the program to be running in the task bar.
    I know how to run the program in the task bar - but I still need to launch the program from the command prompt - is there anyway I can get a program running without having to start it from the command prompt?
    Cheers

    Or create a desktop shortcut (in Windows) or an application launcher ( in Linux GUI).

  • How to invoke multiple sessions of sql*plus thru pl/sql program

    Hi
    How to invoke multiple sessions of sql*plus thru pl/sql program.
    Thanks

    How to invoke sql*plus in a procedure?????
    I have to invoke more pl/sql sessions?????No you don't "have to".
    Look at what you are trying to do.
    You have a program running inside the PL/SQL engine. This is running nicely inside the Oracle database and is perfectly capable of issuing other SQL statements, PL/SQL programs etc. inside it's nice cosy Oracle environment.
    You are asking for this PL/SQL to shell out to the operating system, run an external application, for which it will have to supply a username and password (are you planning on hard coding those into your PL/SQL?), and then that external application is supposed to run more SQL or PL/SQL against the database.
    a) Why hold all this code external to the database when it can quite happily reside on the database itself and be executed through jobs or whatever.
    b) Consider what would happen if someone were to replace the external application with their own program of the same file name... they'd be able to capture the username and password for connecting to the database, therefore a major security flaw.
    The whole idea of doing what you want through external calls to SQL*Plus is ridiculous.

  • How to stop a process chain when its running?

    Dear Experts,
    How to stop a process chain when its running? is it that a chain can be stoppend when we open an info package of that chain ?
    Thank you,
    Raj

    Hi,
    Goto the main menu process chain --> choose the remove from the Schudule...
    Regards
    sathis
    I hope it helps to u... please assign the points

  • How do I remove the hover when I run the click of a second button?

    Good Morning,
    I found half the solution to my problem, that is, the part about the hover state to click on the button:
    1) I converted my Button in ToggleButton
    2) I have added this Style based Triggers:
    <Style TargetType="ToggleButton" x:Key="checkedToggle">
    <Style.Triggers>
    <Trigger Property="IsChecked" Value="True">
    <Setter Property="Background" Value="#5fc3f3"/>
    </Trigger>
    </Style.Triggers>
    </Style>
    To click the button keeps the "hover", the second click will remove.
    Now the other problem: how do I remove the hover when I run the click of a second button?
    Thank You.

    >>Now the other problem: how do I remove the hover when I run the click of a second button?
    You simply set the IsChecked property of the first button to false when the second button is clicked:
    <ToggleButton x:Name="firstButton" IsChecked="True" Style="{StaticResource checkedToggle}">...</ToggleButton>
    <ToggleButton Checked="ToggleButton_Checked" Unchecked="ToggleButton_Unchecked">...</ToggleButton>
    private void ToggleButton_Checked(object sender, RoutedEventArgs e)
    firstButton.IsChecked = false;
    private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
    firstButton.IsChecked = false;
    Please remember to mark close your threads by marking helpful posts as answer and please start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • How to restore system RAM memory when i run DI batch job process

    How to restore system RAM memory when i run DI batch job process
    I use SAP-B12005SP53 and i develop with Business Partner Object

    HI ALL
    TAKE CARE: Nothing was working in VB6, but in .NET it sets the default value !
    from help of VS.
    When you assign Nothing to an object variable, it no longer refers to any object instance. If the variable had previously referred to an instance, setting it to Nothing does not terminate the instance itself. The instance is terminated, and the memory and system resources associated with it are released, only after the garbage collector (GC) detects that there are no active references remaining.
    Garbage Collector distroyes the objects at the end of the sub of function, not in the loop.
    So use local variables when you loading the 7000 items. For me working fine and i do not have a memory problems. I am loading 50000 items with prices from EDI file, and memory usage stops at 120MB.
    1st solution  create a sub or a function to populate the data, and run this for every items by as single rutin,
      sub x
        Dim obj As New Object()
            Try
    ... put here your update code
            Catch ex As Exception
            Finally
                GC.Collect()
            End Try
      end sub
    This free up the memory when Garbage
    2nd solution: use inner loop definition
      sub x
    Try
                Do While True
                    Dim obj As New Object()
                Loop
            Catch ex As Exception
            Finally
                GC.Collect()
            End Try
      end sub
    This free up the memory inside the loop.
    I recommend to use Friend Class keyword for your addon declaration and do not use modules.
    Modules and shared classes will be free up the memory when your program terminates execution.
    For more information see MSDN help http://msdn.microsoft.com/en-us/library/7ee5a7s1(VS.80).aspx
    and http://msdn.microsoft.com/en-us/library/0x9tb07z(VS.80).aspx
    Regards,
    J
    Edited by: János Nagy on Oct 15, 2009 2:17 PM

  • How can i run my java program in background process?

    hi all,
    i am working on desktop monitoring so when i start my program on client machine that is visible to all but i want this program client not visible to all instead of this can be run in background process . so, nobody can see that.
    so, how i can do this ?
    pls pls help me
    thanks in advanced to helper
    regards
    maulik & ritesh

    this will run the java program in the background.It'll just use the Windows Java Console instead of the command-line console. It has nothing to do with running as a background process.
    Edit: though this might be exactly what the OP wants: not "background process" but "no DOS console".

  • URGENT: How to run a Java program from a different directory?

    Hi.
    How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
    What would be the command to run the Java file from c:\Java.
    I can't remember it and I need it asap.
    Cheers.

    If the class you are trying to run is MyApp.class, try
    c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
    Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
    The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)".

  • How do i run a java program an another directory?

    How do I run a java program that's in a different directory?
    I have been doing this in the command line:
    java "C:\Document and Settings\freeOn\Desktop\Java\Test\test"
    and I get
    Exception in thread "main" java.lang.NoClassDefFoundError:
    C:\Document and Settings\freeOn\Desktop\Java\Test\test
    I just thought there might be a quick way to do this and not
    have to cd to the following dir evertime i want to run an app in
    console.
    The test.java file is this:
    import java.io.*;
    public class test {
        public static void main(String args[]) {
          System.out.println("Testing.....");

    Ok I looked in the java help and found the classpath, this makes it alittle easier.
    java -cp C:\DOCUME~1\freeOn\Desktop\Java\Test\ test
    At least i can run this in the run dialog which makes it easier thanks for you help kota balaji

Maybe you are looking for