![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Aug 2007
Posts: 50
OS: Windows Vista Home Premium
|
Command Line Programming
OK, I need help. I'm learning Java for the first time and using command line programming for the first time. My book says to install javac (which I did), and then open a command prompt and type "javac HelloJava.java." When I do this, I get the error "'javac' is not recognized as an internal or external command, operable program or batch file." I realized that this was because, even though the book said type the command EXACTLY, javac.exe is not in C:, it's in C:\Program Files\Java\jdk1.5.0_02\bin. So, I change my directory to now be C:\Program Files\Java\jdk1.5.0_02\bin, and type "javac HelloJava.java" and get the error "error: cannot read: HelloJava.java." The source file is saved to C:\Java Examples\examples\ch002. So now I use the commands "javac C:\JavaExamples\examples\ch002\HelloJava.java" and "javac \JavaExamples\examples\ch002\HelloJava.java", but neither work. how do I do this??????
|
|
|
|
|
|
#2 (permalink) |
|
TSF Enthusiast
Join Date: Jul 2007
Location: Northampton, UK
Posts: 914
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)
|
Re: Command Line Programming
hey, i don't know what the problem you're having with the .java files is as i dont tend to work with java, but it may help if you add the javac program(or the folder it's contained in) to the environment variables "Path" variable (then you can use "javac HelloJava.java" from the folder that HelloJava.java is contained in)... to do this:
In Vista: - click the start bubble thing - right click on "Computer" - Click properties in the context menu it will pop up the system settings dialog in the left hand pane: - click "Advanced system settings" the system properties dialog will open - click the advanced tab and at the bottom right of the content click "Environment Variables" The environment variables popup will open and in the "System Variables" area scroll down and find the entry that has "Path" as the variable, select it and click the edit button below (be careful[you may want to make a copy of its contents incase things go wrong]) Then at the end of whatever's in your path variable's value type ";C:\Program Files\Java\jdk1.5.0_02\bin" (the semicolon states that its another path and adds the path to the path variable... now open your command prompt in the source file's directory "C:\JavaExamples\examples\ch002\" and you should be able to try your origional command ("javac HelloJava.java") p.s. you can do this for any folder to allow use of a program contained in the folder from the command prompt no-matter where you've navigated to... but be careful about it because its a crutial thing. hope that helps you in some way, Jamey |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Aug 2007
Posts: 50
OS: Windows Vista Home Premium
|
Re: Command Line Programming
OK, that solved one problem and created another... I no longer get any errors, but now nothing happens. The program is (obviously) supposed to print "Hello, Java!" to the screen, but nothing happens and the command prompt just gives me another line to enter a command
|
|
|
|
|
|
#4 (permalink) |
|
TSF Enthusiast
Join Date: Jul 2007
Location: Northampton, UK
Posts: 914
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)
|
Re: Command Line Programming
urm, okay. sorry i'm realy not a java developer, does javac compile an executeable or interprete the source? i thought the 'c' would imply it compiles something so look in the same directory for an executeable called HelloJava.exe or possibly in the java's "bin" directory...
if theres one then run it from the command prompt, if its interpreted then i dont know. I've just googled, javac.exe is a compiler, so it should output files not the output of the program, to run the program i think you have to use java.exe but i dont know the exact usage, sorry. Ooo, i've hit something on google again, okay i think i get the rundown of java's compilation steps... Try this: - do "javac HelloJava.java" that should compile the source file into a .class file (to check that type "dir" and look for a "helloJava.class" file) - type "java helloJava" (ensuring you're in the class file's directory) and the java runtime environment should run hellojava... If that doesnt work i'm stumped... if it does then "google is your friend" Hope i helped, Jamey |
|
|
|
|
|
#5 (permalink) |
|
TSF Enthusiast
Join Date: Jul 2007
Location: Northampton, UK
Posts: 914
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)
|
Re: Command Line Programming
p.s. i found the information for that here:
http://java.sun.com/docs/books/tutor...ava/win32.html If what i've said doesnt work try using sun's tutorial and i'm sure it'll work =] |
|
|
|
![]() |
| Thread Tools | |
|
|