How to run Java on Dos prompt

HI~~
I am new to Java and really need help.
I have a program which requires a file as an argument and the file name should be provided as a command line argument.
In dos prompt, how do I tell computer which file is the input file for the program to take as an argument?
Thank you very much for helping me out.

suppose your file in java is Hello.java
Compile it(javac Hello.java) . u get Hello.class
Now suppose your input file is file.txt
So at the command prompt
type
c:\>java Hello file.txt
This will cause the args[0] to be initialised to file.txt
How to use it , u have to figure out.
Regards
Manoj.

Similar Messages

  • Run java in dos

    anyone can tell how to use dos to run Java program?
    I learn Eclipse few month, so I dont know how to run java in dos. I did follow the install guide to set the PATH like that
    C:\Program Files\Java\jdk1.5.0_02\bin in "Path" in the User Variables
    but I type to run by typing "
    *c:>javac welcome1.java*
    it says "javac is not in internal or external command to execute this file.
    Did I miss something in that?
    Please kind help!!!

    did you have any luck in figuaring out how to use the dos compiler. You have to use a simple text editor like WordPad and then you save all your files in the same dir. I have been using a dos compiler for school, even thought I don't really care for them. It has been great practice getting around in dos again. And you don't have to access the Run Time Enviroment to get your program to run. just complie then first with javac filename.java and then run them with java filename.

  • Running java fro DOS windows

    Hi, can somebody tell me how to run java files from the DOS window, in windows??? thanks

    joej wrote:
    ok, thanx, i did and i found i should write this javac javafile.java, but when i did i got this error "javac is not recognized as an internal or external command, operable program or batch file, what does that mean or what could it be causing it?In the dos-shell, when you type "javac" or any other commands, the shell searches it's available path for the command. In this case, "javac" was not included as part of the path that the does shell searches and therefore it returned that error.
    Go to google and search for how to add javac to source path.

  • How to run java signed applet in vista with changing IE security options

    how to run java signed applet in vista with changing IE security options. If i change the IE security settings to low. it works.
    without changing the security setting, how to run.

    j_nanaji9 wrote:
    how to run java signed applet in vista with changing IE security options. If i change the IE security settings to low. it works.
    without changing the security setting, how to run.Can't be done without changing the security setting.

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

  • How to run .java file in windows ?

    How to run .java file in windows without installing any program? Thx!

    First, U must make sure that there is JDK on your computer
    Then, set the envionment variables which the os can find your compiler and interpreter: javac java
    after those, you must complie your .java file to .class file, then you can excute it by java, for example " java helloworld"

  • How to run java using xcode?

    i have to install "java developer " but i can't find, where i can run Java, Please give me information about "how to run java use xcode " ?

    Download the SDK from Oracle, code, enjoy.

  • How to run Java program as Daemon Server in linux

    How to run Java program as Daemon Server in linux
    i would like to run the java program on system start up in a redhat linux system
    can any one provide rc.status file

    http://wrapper.tanukisoftware.org/

  • How to run java servlet without using Web.xml?

    How to run servlet without using Web.xml? From a book, I know that web.xml descriptor is optional, but the book doesn't tell us how to run java servelet without web.xm descriptor. So how to do that? Thanks a lot.

    How to run servlet without using Web.xml?But Tomcat now uses a web.xml for its global server-wide configuration.
    If you'd like to invoke a servlet with:
    http://host/servlet/ServletName
    you have to enable the invoker servlet.
    [from an HTML]
      <FORM METHOD="POST" ACTION="/servlet/HGrepSearchSJ">
    [from resin.conf of Resin Web Server 2.1.12]
      <!--
         - The "invoker" servlet invokes servlet classes from the URL.
         - /examples/basic/servlet/HelloServlet will start the HelloServlet
         - class.  In general, the invoker should only be used
         - for development, not on a deployment server, because it might
         - leave open security holes.
        -->
      <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    [from TOMCAT5.0.19/conf/web.xml, a global server-wide web.xml file]
      <!-- The "invoker" servlet, which executes anonymous servlet classes      -->
      <!-- that have not been defined in a web.xml file.  Traditionally, this   -->
      <!-- servlet is mapped to URL pattern "/servlet/*", but you can map it    -->
      <!-- to other patterns as well.  The extra path info portion of such a    -->
      <!-- request must be the fully qualified class name of a Java class that  -->
      <!-- implements Servlet (or extends HttpServlet), or the servlet name     -->
      <!-- of an existing servlet definition.     This servlet supports the     -->
      <!-- following initialization parameters (default values are in square    -->
      <!-- brackets):                                                           -->
      <!--                                                                      -->
      <!--   debug               Debugging detail level for messages logged     -->
      <!--                       by this servlet.  [0]                          -->
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    ---comment out below----------------------------------------------------------
        <!-- The mapping for the invoker servlet -->
    <!--
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
    -->

  • How to run Java Card 2.2.1 demo application?

    Hi Friends..
    i want to know how to run Java Card 2.2.1 demo application in Windows environment..
    Sorry, perhaps this question looks like a little bit stupid.. :(
    In Windows, I've set the environment variables for :
    JAVA_HOME : C:\Program Files\Java\jdk1.6.0_03
    JC_HOME : C:\java_card_kit-2_2_1
    and then how to run demo1.scr, etc?.
    Please help me regarding this,
    Thanks in advance..

    Is there any suggestion for my question?.. :(
    Thanks in advance..

  • Urgent ! how to run swing from dos

    hi
    how should i run swing program through dos prompt.when found in i tried compiling from c:\jdk\bin i got an error "package javax.swing not import".
    viji

    what you willdo is this,
    at the top of your code type the line.
    import javax.swing.*;
    //for event type the next line..
    import javax.swing.event.*;
    import java.awt.event.*;
    I think this should solve your problem.

  • Filepath probs running Java w/ DOS and Java 2 SDK

    Please help! I have been trying to get a .class file to run for the past four days, using DOS to run the file. I have tried to enter every filepath I can -think- of, and the program still will not run. I have even tried running the file on others' computers that also have a Java 2 SDK...and still cannot get the file to run. However, I know for certain that the file is correct and is able to be run....so that means that somehow I am not putting in the right filepath. I guess my question is....what's the file path?
    Here's what I was told to do...which has not worked thus far...
    My Java SDK filepath is: C:/Java2SDK1.4.0
    I was instructed to open DOS, then, to get to here:
    C:\Documents and Settings\Administrator\Desktop>I did so, and as instructed entered the filepath to the javac file inside the java sdk and after it, to put the filename with a .java extension. However, I ONLY have a class file. I don't have the .java file, nor was it ever handed to me.That filepath requested is: C:/Java2SDK1.4.0/bin/javac MathPrac.java
    I entered the filepath, so my DOS prompt looked like this before I hit the enter key:
    C:\Documents and Settings\Administrator\Desktop>C:/Java2SDK1.4.0/bin/javac MathPrac.javaI hit enter, and it gives me a LONG list of garbage. I even tried reversing the slash marks. Please help? This thing is due Monday and my instructor is refusing to return my emails. I don't want to fail this course due to an instructor being unwilling to assist a student, and a student having tried just about everything she could think of before finally coming here and asking for help.
    Would it matter if the SDK for some reason won't recognize my .java files either? I even tried doing the filepath with a file I KNOW should work...and on computers it should have worked on...and could not get it to accept my filepath.
    Any help would be very very very highly appreciated. Thanks!

    Author: philip_ross
    To run a .class file you have to use the java command (javac is the compiler which creates .class files from .java files). Try running
    C:\Java2SDK1.4.0\bin\java MathPrac
    Thank you for the suggestion, however when I attempted to run it, I got an error that said: Exception in thread "main" java.lang.NoClassDefFoundError: MathPrac
    Isn't this an error that states that the name of the file and the class name inside the file are not the same? And if so, how can I check to see if they are the same if I don't have the .java file? I did double-check my spelling, tried it four times just to be sure.
    To ChuckBing:
    Hey, thanks for the tutorial! I'll take a look at that, too. It always helps to have other resources.
    To jwenting:
    <Grin>. Duly noted, and thanks. I was trying to keep from being -too- technical in my explanation of what was going on.

  • How to run java from another directory

    hi,
    i have a Sample.java file in F drive(f:/Sample.java). I opened command prompt in windows and went to c: drive and try to compile as
    C:\>javac f:/Sample.java
    above command works well. it generated Sample.class file in F:/Sample.
    But, when i try to Run that file, i got the error as follow.
    C:\>java f:/Sample
    Exception in thread "main" java.lang.NoClassDefFoundError: f:/Sample
    Caused by: java.lang.ClassNotFoundException: f:.Sample
    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: f:/Sample. Program will exit.
    Please guide me to run java file from another directory

    Thanks a lot. I appreciate your answer
    But, when i try to run the java program.. below message has been displayed, showing how to use the command with options....
    I didn't get the result of java program.
    c:\>java f:\Sample.java
    C:\>java -cp f:\Sample
    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:\>

  • How to run java program created in Sun Java Studio

    Hi All,
    sorry for easy question. I'm new in java.
    I have created Swing/AWT application with Sun Java Studio. I can run it using Sun Java Studio and it works properly. How to run this application in DOS-promt using "java ....."? I think, I shall define all classpathes but I dont know exactly.
    Enviroment:
    WinXP
    Sun Java Studio (C:\Sun\studio5u1_se)
    SDK (C:\Sun\j2sdk1.4.2_04)
    Application files (C:\Sun\My)
    Thanks.

    change this to yours
    set path=c:\j2sdk1.4.1_01\bin;c:\j2sdk1.4.1_01\jre\bin;%path%
    set classpath=c:\j2sdk1.4.1_01\lib;c:\jdk1.4.1_01\jre\lib;%classpath%
    go to directory where code is
    javac CLASSNAME.java
    then to run it
    java CLASSNAME
    note also look at executable jar files

  • How to run Java JDBC-Applet in Internet Explorer Browser?

    I developed an java application which uses JDBC thin client driver to fetch data from oracle 8i tables, applet to display some graphics.
    I am able to compile to code in dos prompt.
    Iam unable to run using Appletviewer and IE browser.
    In IE browser it displays applet started in status bar but it displays nothing.
    In appletviewer it gives
    Warning : Can't read appletviewer properties file :c:\.....
    java.security.AccessControlException......security expression specifying database host and port.
    Environment : Oracle 9iDS release 2.0
    Can anybody help me by providing the solution.

    http://java.sun.com/developer/technicalArticles/Security/applets/
    - Saish

Maybe you are looking for

  • How to change the background color only for one HTML-Portlet?

    Hi all, I have created a HTML-Portlet in my root-page. The root page have a style: Main-Style. I want to change the background-color only for this one HTML-Portlet: <html> <header><title>Test</title></header> <body bgcolor="#999999"> Test </body> </h

  • How to get audit id in coder template mapping

    Hello everybody, i am new in this Forum and new to the Oracle Warehouse Builder. I am Student and currently working on a approach of error handling by ETL processes. To my question: I am using a Code Template Mapping to load data in my target tables.

  • Payment throught EDI IDoc to Bank

    Hi, I have created a new payment method to pay customer credit through EDI IDoc. I have tested in F110 (APP), document getting cleared and IDoc also getting created. After this I'm not sure what I need to do. Kindly tell me the action points with Tco

  • Best settings for project with multiple format sources

    New to Premiere Pro after leaving FCP behind and I feel like I've got enough under my belt to start a new project. Working in PP CS6. Question: my source footage is going to be in many different formats from ripped flash video to footage shot on a C3

  • Removal of Expired contract type

    Hello friends, My client requirment is expired contract type should be removed from the list. They are saying, 'The Accounts team some time selects that contract for raising invoice instead of new contract created for the sameĀ  rentalĀ  object. How ca