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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > The Conversation Pit > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
Thread Tools
Old 03-31-2008, 10:50 AM   #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??????
sbussy89 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 03-31-2008, 11:48 AM   #2 (permalink)
TSF Enthusiast
 
jamiemac2005's Avatar
 
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
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 03-31-2008, 03:52 PM   #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
sbussy89 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 03-31-2008, 05:38 PM   #4 (permalink)
TSF Enthusiast
 
jamiemac2005's Avatar
 
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
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 03-31-2008, 05:40 PM   #5 (permalink)
TSF Enthusiast
 
jamiemac2005's Avatar
 
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 =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 08:09 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82