compiler problems...

Hello,
I am a complete newbie, trying to get a "hello world" type program to run. I have the "j2sdk1.4.2_08" of java. My problem is as follows: I go to the start menu, click on the "run" botton, type in "cmd", and type "cd C:/j2sdk1.4.2_08" into it. now I type "dir",I type in C:j2sdk1.4.2_08in/javac.exe (where java is located on my computer) javac javatest.java.txt. When I attempt this, the following appears on the screen:
" 'C:/j2sdk1.4.2_08/bin.exe' is not recongized as an internal or external command, opperable program or batch file.

C:j2sdk1.4.2_08>C:js2dk1.4.2_08injavac.exe javac javatest.java.txt
javac: invalid flag: javac
Usage: javac
were possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-depreciation Output source locations where deprecated APIs are used
-Classpath Specifiy where to find user classs files
-sourcepath Specify where to find input source files
-bootclasspath Override location of installed extensions
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-help Print a synopsis of standard options"

Any and all help will be appreciated.

Thanks in advance,
aticper.

(note: the error message is hand typed, so if anythng looks like it might be a typo, it probably is).


Comments

  • [code]
    : C:j2sdk1.4.2_08>C:js2dk1.4.2_08injavac.exe javac javatest.java.txt
    [/code]

    Rename the text file to a .java file. The file name case needs to match the declared class (so if the class is called JavaTest):
    [code]
    ren javatest.java.txt JavaTest.java
    [/code]

    Don't put in the 3nd javac:
    [code]
    C:j2sdk1.4.2_08>C:js2dk1.4.2_08injavac.exe JavaTest.java
    [/code]

    Assuming there is a main method in JavaTest, run it:
    [code]
    C:j2sdk1.4.2_08>C:js2dk1.4.2_08injava.exe JavaTest
    [/code]

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • Hello,
    Thank you for your reply. Unfortunately, when I copied and pasted your suggestions into the command prompt window, all that happened was that it gave me more error messages. If you have any suggestions as to what I may be doing wrong, they will be much appreciated.

    Thank you again!

    aticper
  • : Hello,
    : I am a complete newbie, trying to get a "hello world" type program to run. I have the "j2sdk1.4.2_08" of java. My problem is as follows: I go to the start menu, click on the "run" botton, type in "cmd", and type "cd C:/j2sdk1.4.2_08" into it. now I type "dir",I type in C:j2sdk1.4.2_08in/javac.exe (where java is located on my computer) javac javatest.java.txt. When I attempt this, the following appears on the screen:
    : " 'C:/j2sdk1.4.2_08/bin.exe' is not recongized as an internal or external command, opperable program or batch file.
    :
    : C:j2sdk1.4.2_08>C:js2dk1.4.2_08injavac.exe javac javatest.java.txt
    : javac: invalid flag: javac
    : Usage: javac
    : were possible options include:
    : -g Generate all debugging info
    : -g:none Generate no debugging info
    : -g:{lines,vars,source} Generate only some debugging info
    : -nowarn Generate no warnings
    : -verbose Output messages about what the compiler is doing
    : -depreciation Output source locations where deprecated APIs are used
    : -Classpath Specifiy where to find user classs files
    : -sourcepath Specify where to find input source files
    : -bootclasspath Override location of installed extensions
    : -d Specify where to place generated class files
    : -encoding Specify character encoding used by source files
    : -source Provide source compatibility with specified release
    : -target Generate class files for specific VM version
    : -help Print a synopsis of standard options"
    :
    : Any and all help will be appreciated.
    :
    : Thanks in advance,
    : aticper.
    :
    : (note: the error message is hand typed, so if anythng looks like it might be a typo, it probably is).
    :
    :


    Try setting up your compiler properly so you do not have to include the path to javac on the command line.

    http://java.sun.com/developer/onlineTraining/new2java/programming/learn/

    When you set up your classpath, put the path to bin at the front of the string, if you are using windows, there is a weird bug that causes problems if it is put at the end. Do not forget to add a ; at the end of the path to bin. Also try not to put your .java files in the java directory, create a seperate directory for your programs.


  • Thank you for your reply.

    I re-downloaded java, and now it runs perfectly.

    thanks agai,

    aticper


  • " When you set up your classpath, put the path to bin at the front of
    : the string, if you are using windows, there is a weird bug that
    : causes problems if it is put at the end. Do not forget to add a ; at
    : the end of the path to bin. Also try not to put your .java files in
    : the java directory, create a seperate directory for your programs."
    :


    thanks!! useful info!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories