JAVA-command prompt help

I am creating a text-based application and want to make it in to a application. When I create and run the .jar file, the message box that I am using to test the running of an application, appears but the command prompt does not open and display the text I have there. How do I get the application to open the command prompt window?

Well, LordOfTheLost, you have a most persistent problem. I have used these exact methods to get my System.out.print() and System.out.println() trace comment to echo to the command window. Have you redirected your Standard out? What come up in the message box? I don't know of a Windows setting to change to alter you problem.
When you are running in Windows and you output to standard out (System.out.print) then it is just ignored, but when you are in a dos console, it outputs to the command lines.

Similar Messages

  • Java Command Prompt Commands

    This is a stoopid question and I've searched the forums, but what is the command in DOS prompt to view your classpath.
    When I run java -classpath it gives me all the various options e.g.
    java -cp -classpath
    but non of these work? whats the craic?
    M.

    What do you mean by "none of these work"?
    Suppose that you have a file HelloWorld.class in the directory C:\MyClasses. If you type:
    java -classpath C:\MyClasses HelloWorld
    it should run your program without problems.
    Are you getting an error message? What's the error message?
    Jesper

  • 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.

  • 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:\>

  • Problem with executing java on command prompt

    Hi my program uses java mySQL connector to connect to a local host. The program works fine when i run through netbeans. But when i run through command prompt it gives in this error message
    java.lang.ClassNotFoundException:com.mysql.jdbc.Driver Can anyone help me to solve this problem

    add mysql.jar file to ur classpath, it will work fine.

  • Runtime.exec() I need to run a command prompt command from java.

    the code i have that doesn't seem to work is:
    String driveloc = System.getProperty("user.dir").substring( 0, 1 );
            String path = jTextFieldPath.getText();
            String path2 = jTextFieldPath.getText().substring(0, jTextFieldPath.getText().length()-3) + "lst";
            String[] cmd = { "cmd.exe", "/" + driveloc, "ASMtools\\AS11 " + path + " -L >" + path2};
            txt_mf.append( cmd[3] );
            try {
                Process np = Runtime.getRuntime().exec( cmd );
            catch( java.io.IOException ioe) {
                //error
            }jTextFieldPath.getText() contains the path of the file saved by my program.
    the line of code i am trying to run is:
    AS11 FILE1 -L FILE2this line compiles the asm file and converts it to a lst creating an s19 file in the process. AS11 is an exe that aids the command prompt much like javac.
    If you could help me figure this out it would be great.
    Thanks in advance,
    -Juke

    String driveloc =
    System.getProperty("user.dir").substring( 0, 1 );
    String[] cmd = { "cmd.exe", "/" + driveloc,
      "ASMtools\\AS11 " + path + " -L >" + path2};Are you sure you want to invoke cmd.exe with the switch /c or /d or whatever depending on System.getProperty("user.dir") ?
    Starts a new instance of the Windows 2000 command interpreter
    CMD [A | /U] [Q] [D] [E:ON | /E:OFF] [F:ON | /F:OFF] [V:ON | /V:OFF]
        [[S] [C | /K] string]
    /C      Carries out the command specified by string and then terminates
    /K      Carries out the command specified by string but remains
    /S      Modifies the treatment of string after /C or /K (see below)
    /Q      Turns echo off
    /D      Disable execution of AutoRun commands from registry (see below)
    /A      Causes the output of internal commands to a pipe or file to be ANSI
    /U      Causes the output of internal commands to a pipe or file to be
            Unicode
    /T:fg   Sets the foreground/background colors (see COLOR /? for more info)
    /E:ON   Enable command extensions (see below)
    /E:OFF  Disable command extensions (see below)
    /F:ON   Enable file and directory name completion characters (see below)
    /F:OFF  Disable file and directory name completion characters (see below)
    /V:ON   Enable delayed environment variable expansion using c as the
            delimiter. For example, /V:ON would allow !var! to expand the
            variable var at execution time.  The var syntax expands variables
            at input time, which is quite a different thing when inside of a FOR
            loop.
    /V:OFF  Disable delayed environment expansion.

  • Trying to find a way to execute from command prompt using java....

    I want to find a way to execute a command from the command line using a java program this is my code:
    import java.io.*;
    public class SQLHopefully
         public static void main(String[] args)
              try{
              Runtime rt = Runtime.getRuntime();
              Process proc = rt.exec("cmd /k start cmd.exe");
              OutputStream out = proc.getOutputStream();
              System.out.println(out);
              out.write("test.txt".getBytes()); //I THOUGHT THIS WOULD WORK
              InputStream stdin = proc.getErrorStream();
              InputStreamReader isr = new InputStreamReader(stdin);
              BufferedReader br = new BufferedReader(isr);
              String line = null;
              while ( (line = br.readLine()) != null) {
              System.out.println(line);
              stdin = proc.getInputStream();
              isr = new InputStreamReader(stdin);
              br = new BufferedReader(isr);
              line = null;
              while ( (line = br.readLine()) != null) {
              System.out.println(line);
              int exitVal;
              try {
              exitVal = proc.waitFor();
              } catch (InterruptedException e) {
              throw new IOException(e.getMessage());
              if (exitVal != 0) {
              throw new IOException("Exit value was " + exitVal ");
              }catch(IOException e)
              {System.out.println("ummmmm");}
    I hope my code is readable. I am trying to get the command prompt that comes up from the Runtime.exec() to run a file called "test.txt" I know it would be easier to just do it by executing it from java but I want to see if it is possible this way. I thought the out.write would do the trick but I was wrong. Somebody help please....
    Nate

    First read this article:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Second, you should probably send the Enter key to the shell if you want anything to happen. (Not that I know whether it will work, but I do know it won't work if you don't press Enter.)

  • How i can open a new command prompt from one java from

    hi
    can any one help me that how i can open a command prompt by using the java program file .
    regards,
    ukbasak

    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#exec(java.lang.String)
    and several overloads.
    Also
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html

  • How to install Java to compile Sevlets at command prompt

    Please help me to compile my java servlets at command prompt.
    I have buyed a new leaptop with windows XP service pack 2
    I have downloaded Java EE 5 SDK Update 4 (with JDK 6u5) for Windows, English
    I setted my path and classpath variable for bin and lib folder..
    I could not able to compile my servlet programs
    I am getting errors for all my servlet package classes and servlet.http. packages.........

    Hi Jeff,
    Follow the steps ...
    First you install JDK, it can be 1.2, 1.3, 1.4.
    Lets say you install it in c:\jdk13\ then c:\jdk13 becomes your Java Home Path.
    Edit your autoexec.bat using any editor. And add the Following Lines.
    SET CLASSPATH=C:\JDK13\SRC.JAR;C:\JDK13\LIB\TOOLS.JAR;C:\JDK13\LIB\DT.JAR
    These are the Jar files that need to comile and execute your Java Programs.
    Next add the JDK Binary executables folder in the Windows Path.
    Add this line to the end of your Autoexec.bat
    PATH=%PATH%;C:\JDK13\BIN
    The %PATH% Variable will append the Bin path to the existing path.
    Dont worry about the Case of the statements but dont Leave Spaces after in between after the PATH= Words in any of the above statements.
    Its reccomended to Restart your PC for these commands to take effect.
    Then write a Java Class and compile it with javac yourClass.java and then run it with java yourClass
    Hope this is clear enough.
    Regards ,
    Max

  • Running Java without Command prompt support

    Hi,
    Can I run my class file without showing the command prompt in background.
    I tried with javaw, but its not working. I have jdk1.5 installed.
    please help me

    Jar files (<wavey subliminal type effect>search button</wavey subliminal type effect>) are on most modern OSes double clickable.
    http://java.sun.com/docs/books/tutorial/jar/index.html

  • Manipulating Windows command prompt through Java

    I am wondering if there is any way to manipulate simple Windows command prompt commands like color, cd, dir, cls through a java application. Any help or informative redirection would be much appreciated.

    BinaryBurnout wrote:
    I am wondering if there is any way to manipulate simple Windows command prompt commands like color, cd, dir, cls through a java application. Any help or informative redirection would be much appreciated.Realize that the Windows command prompt is an application (cmd.exe), and those commands are specific to that application.

  • Invoking command prompt & executing a java class from one more java class

    Hi,
    I have a problem with my application. I need to develop an editor which compiles and interpretes java programmes. I am develoopping it in Java (Swing and pure Java). I have no problem in compiling a java programme from my editor. But while execuing if any body writes a programme which has console input the system hangs. I am using Runtime.exec() method to call command prompt of Win'2000. My editor is working fine for the programmes written without console input in my editor. I want the same type of input acceptance as JCreator / Vim editors accept.
    How can i achieve this? Please give me some source code help for my requirement.

    When you create a Process object from executing a command you can grab it's input and output streams. Using these, and a text area, you can create a "virtual terminal" for your user to work with their console programs. The rest is just details :)

  • Using java from command prompt

    Hi, I have used command prompts for a long time, though not recently. But this has never happenned to me, and I may have been using a different OS the last time I really used a command prompt. I am currently running Windows XP.
    Anyways, when I try to simply change a directory, you know cd "filename", it tells me:
    Parameter format not correct - "filename"
    Basically, it won't accept any strings as a parameter. I'm really surprised at this. Is this normal? In any case, I got around this by using the short names for files. For example, I used the name docume~1 instead of "documents and settings".
    Then, when I got to the folder where my java files were stored, it told me it was an invalid directory but nonetheless allowed me to use it. However, no commands worked except for cd..
    Java did not work, nor did basic commands like dir or help. Do you have any idea what is wrong with my command prompt? I know this is not specifically a question about Java, but I can't use Java without this.
    thanks.

    Basically, it won't accept any strings as a parameter.
    I got around this by using the short names for files. For example, I
    used the name docume~1 instead of "documents and settings".So it is accepting some strings.
    Check that you are using cmd.exe not command.com. Ie, from
    Start->Run... typecmdAnd not command.
    Try the javac command and if the computer says'javac' is not recognized as an internal or external command,
    operable program or batch file.then will have to set your OS path (not CLASSPATH - do not set
    CLASSPATH at any time or the command prompt will likely never work
    again).
    Instructions for setting the OS path are [urlhttp://java.sun.com/j2se/1.5.0/install-windows.html]here. Scroll down to
    point number 5

  • Errors while Executing a scenario thruogh command prompt...Pls help!!

    hi,
    i am trying to execute a scenario in my command prompt.i am using windows operating system.
    i am getting the the following error when i run this command..
    startscen COM_IFLEX_LIMITS 001 GLOBAL "-V=2"OracleDI: Starting scenario COM_IFLEX_LIMITS 001 in context GLOBAL ...
    java.sql.SQLException: ORA-00942: table or view does not exist
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :125)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.
    java:185)
    at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPrepa
    redStatement.java:503)
    at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleState
    ment.java:965)
    at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPre
    paredStatement.java:535)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:1051)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrep
    aredStatement.java:2984)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePrepare
    dStatement.java:3026)
    at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
    at com.sunopsis.dwg.DwgObject.refresh(DwgObject.java)
    at com.sunopsis.dwg.cmd.e.h(e.java)
    at com.sunopsis.dwg.cmd.e.g(e.java)
    at com.sunopsis.dwg.cmd.e.y(e.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    DwgJv.main: Exit. Return code:-1
    Regards
    Ashwin

    So we can understand where the error occurs, can you tell us where the processings gets up to in the log?

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

Maybe you are looking for

  • Using Element 31" LCD TV as display

    I have a 2008 macbookpro15 with the big video output plug on the upper right side as you face the computer. In the past I have used it successfully with my 2008 vintage 46" samsung to display photos stored in iphoto. (mac output to HDMI input). now w

  • [Feature Request] 'Duplicate Tab' in Tab Dropdown

    I know now that you can duplicate a tab by Control-clicking or middle-mouse-buttoning the Reload button, or by Control-dragging the tab over. But what would have been most intuitive is if there were an option to do this in the tab dropdown. I'm more

  • Connecting Mobile Phone to HomeHub2

    For a year or so now I have had no problems connecting my HTC Legend phone to the internet. Now I cannot connect at all. The phone picks up the strong wireless signal, but the connection process stops at 'Obtaining address'. It's the same problem on

  • Installation problem, SQL developer does not start

    Hi, I have tried to install both version of SQL Developer, with and without JRE. But when I click the sqldeveloper.exe file nothing happens. Nothing at all! Do any of you have any tips or ideas what the problem could be? I have the latest java jdk in

  • Browser Cookies

    I have just got a new Nokia 6210 Navigator, and when i go to view my msn hotmail account it comes back with the message that the browser need to be set to allow cookies on the unit. I have looked through the phone and it lookes like the cookies are s