Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
compiler problems... Posted by aticper on 7 Aug 2005 at 5:27 PM
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_08\bin/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_08\bin\javac.exe javac javatest.java.txt
javac: invalid flag: javac
Usage: javac <options> <source files>
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 <path> Specifiy where to find user classs files
-sourcepath <path> Specify where to find input source files
-bootclasspath <pathH? Override locaiton of bootstrap class files
-extdris <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> 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).


Report
Re: compiler problems... Posted by arb123 on 8 Aug 2005 at 1:16 AM
: C:\j2sdk1.4.2_08>C:\js2dk1.4.2_08\bin\javac.exe javac  javatest.java.txt


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):
ren javatest.java.txt JavaTest.java


Don't put in the 3nd javac:
C:\j2sdk1.4.2_08>C:\js2dk1.4.2_08\bin\javac.exe JavaTest.java


Assuming there is a main method in JavaTest, run it:
C:\j2sdk1.4.2_08>C:\js2dk1.4.2_08\bin\java.exe JavaTest


---------------------------------
HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html

Report
Re: compiler problems... Posted by aticper on 11 Aug 2005 at 7:09 AM
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
Report
Re: compiler problems... Posted by Vilanye on 11 Aug 2005 at 9:45 AM
: 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_08\bin/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_08\bin\javac.exe javac javatest.java.txt
: javac: invalid flag: javac
: Usage: javac <options> <source files>
: 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 <path> Specifiy where to find user classs files
: -sourcepath <path> Specify where to find input source files
: -bootclasspath <pathH? Override locaiton of bootstrap class files
: -extdris <dirs> Override location of installed extensions
: -d <directory> Specify where to place generated class files
: -encoding <encoding> Specify character encoding used by source files
: -source <release> Provide source compatibility with specified release
: -target <release> 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.


Report
Re: compiler problems... Posted by kostas_exarhia on 15 Aug 2008 at 11:32 AM

" 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!
Report
Re: compiler problems... Posted by aticper on 16 Aug 2005 at 2:32 PM
Thank you for your reply.

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

thanks agai,

aticper




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.