• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Command Prompt ?

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Downloaded,Location-Local Disk(C in program files,Java\jdk 1.6.0_02 What do I need to type at command prompt in order for java to work?Have followed the tutorial to the step of copying the HelloWorld file, but am unable to create the source file,am stuck at this point.Java seems to be installed on C drive,have only one drive.No java or javac at command promt.Any ideas?Thank You.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you update your PATH variable, as described in step 4 of the Installation Instructions for Windows?
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would the path varible be per my install?java\bin\1.6.0_02 Am unsure as to the exact path.Have gone to where path is set,but need to know exactly what to type.Please stay with me,I feel I am finally getting there ThankYou.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Smith:
What would the path varible be per my install?java\bin\1.6.0_02 Am unsure as to the exact path.Have gone to where path is set,but need to know exactly what to type...


It sounds like you should add the following to your PATH...

C:\Program Files\Java\jdk1.6.0_02\bin

You should probably add this to the right end of whatever is already there. For Windows, PATH items are separated with a semicolon. So just add a semicolon to the right of your existing PATH, and then add the above path. Make sure there are no extra spaces. So it would be...

<whatever you already have for a path>;C:\Program Files\Java\jdk1.6.0_02\bin

You will need to open a new Command Prompt for this to take effect. You might even need to reboot.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
marc weber thank you for reply.Will try this later today and let you know the results.Thanks Again for your help.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You for reply.In Enviromental Variables PATH is C:\WINDOWS\system32;C:\WINDOWS... New or Edit box to add my java version?Is this the correct way?Thank you again.
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Smith:
Thank You for reply.In Enviromental Variables PATH is C:\WINDOWS\system32;C:\WINDOWS... New or Edit box to add my java version?Is this the correct way?Thank you again.



Highlight the PATH line and click the EDIT button and add your information (as shown above) in the edit box to the right of what is already there.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider how the PATH variable works.

The PATH variable is a list of different paths, separated by semicolons (at least in Windows). When you type a command like "javac" and the system can't find it in the current directory, it uses the PATH variable to try and find that command. From left to right, it tries each of the paths listed until it finds one that works. For example...

Is "javac" under C:\WINDOWS\system32? Nope. Check the next item. Is "javac" under "C:\WINDOWS\whatever? Nope. Check the next item... Eventually it will find the item you added to the end of the list. Is "javac" under C:\Program Files\Java\jdk1.6.0_02\bin? Yes! So it executes.

This is why you want to EDIT what is already there instead of creating a new variable. You need to keep the existing path items where they are. And by adding your value to the end of the list (at the right), you won't mess up anything that's currently working with one of the existing values.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THANK YOU,THANK YOU,THANK YOU!I had been struggling with this step for quite a while,now at command prompt java works and so does javac.Now I'll start the tutorial from begining,and go from thiere.Thanks Again for your help and patience.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,cd C:\java does not change the directory as tutorial states.Do I need to typeC:\ProgramFiles\Java\jdk1.6.0_02\bin ?What do I need to do to get the change C:\java?
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Smith:
...Do I need to typeC:\ProgramFiles\Java\jdk1.6.0_02\bin ? ...


No, you should not be putting your own files under the JDK's bin directory, so there should be no reason to change to that directory.

Do you have a directory called "java" on "C"? If not, you need to create this first.

What error message are you getting when you try to change to that directory? Can you copy and paste exactly what you're seeing?
[ August 20, 2007: Message edited by: marc weber ]
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is located in C: in Program Files.How do I create a directory that I can use?At command prompt when I try to cd C:\java-The system cannot find the path specified.Have followed the tutorial exactly as per thier instructions.Thanks for the reply.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Smith:
Java is located in C: in Program Files.How do I create a directory that I can use? ...


The "Java" directory under Program Files should be left alone. You want to create your own directory somewhere else, like directly under "C."

There are a few ways to do this. In Windows, I usually use Windows Explorer (Start Button > Programs > Accessories > Windows Explorer). Select the location you want, then choose File > New > Folder.

You could also do this using My Computer (which should have a desktop icon). Double-click the drive you want (C), and then use "File and Folder Tasks" to "Make a new folder."

Or at the command prompt, you can just use the md (make directory) command. For example...

C:\>md MyJava
[ August 21, 2007: Message edited by: marc weber ]
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Went to My Computer,made My Java file.Now when I try C:\>md My Java-access is denied at command prompt.Java now shows at dir in command prompt.Thank You for reply.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A subdirectory or file already exists,when I type cd java.Will keep trying the tutorial,if not successful,will try another approach.Thanks Again for your help.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you've already created the directory using My Computer, then there's no need to use "md" (make directory) at the command prompt. These are just 2 different ways of accompilshing the same thing: Creating a new directory.

I don't know what the access denied issue is. If this seems to be an issue, please post exactly what is showing in your command prompt window.

If you already have a "Java" directory created under C, then your command prompt should look like this when you use "cd" to change directories...

C:\>cd Java
C:\Java>

From there, you should be able to compile and run your HelloWorld program stored in that directory.

C:\Java>javac HelloWorld.java
C:\Java>java HelloWorld
Hello World!

C:\Java>

So are you able to compile and run Java files from that directory?
[ August 21, 2007: Message edited by: marc weber ]
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cd C:\Java Message is-'C:\' is not recognized as an internal or external command.operable program or batch file.Thank You for reply.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't have to enter the "C:\" drive part -- just type "cd" followed by a space and the directory name. For example...

C:\>cd Java
C:\Java>
[ August 21, 2007: Message edited by: marc weber ]
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Followed your directions to create a new directory,created new file,but what should be located in this file?All files are on C,Java is in C in the Program Files.At the prompt Java is listed in the dir,cd java does not work.Why does this not work,have done exactly as the directions state.Thank You
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I see that my last post was missing a detail about the default prompt in Windows. (I only use Windows at work, and my environment is set up a little differently.)

You should have a directory that you created for your own Java files -- for example, C:\Java. When you save your HelloWorld.java file, this is where you should put it (under C:\Java).

When you open a new Command Prompt, the default prompt will probably be your home directory. (This is the detail I was missing.) For example...

When you type "cd C:\Java" at this prompt, it should change the current directory (and the prompt) to "C:\Java."

At this point, the current directory (C:\Java) should contain the HelloWorld.java file that you saved there eariler. To compile this file, type "javac" followed by a space and the file name (including the .java extension). If this compiles successfully, you will get your C:\Java prompt back.

To run this program, type "java" followed by the class name (without any extension). The output should appear on the next line.

If you get any error messages, please tell us exactly where this occurred and exactly what it says.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I'm not sure which tutorial you're using, but Sun's Hello World Tutorial for Windows provides nice details with Command Prompt graphics.
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Local Disk(C created file (C JAVA) for HelloWorld.java Is this correct.Do I need all of the java files,the jdk6 and HW on 1 seprate file?I am using the Sun tutorial.Java jdk6 is now located in program files on drive C, what am I doing wrong,have followed the tutorial to the letter.Thank You for reply.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry, I need more specific information about what you're doing. Can you start with a brand new Command Prompt, repeat your steps in trying to compile and run this, then copy everything that's on your Command Prompt screen?

To copy, you will need to right-click on the Command Prompt and select "Mark." Then highlight the entire area you want to copy and press the Enter key. Paste your results in a post here.
[ August 22, 2007: Message edited by: marc weber ]
 
Mike Smith
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You for all your help and patience.This was about to drive me nuts.On another forum(Sun)someone gave me the line cd /d"c:\C JAVA and it finally got me to C:\C JAVA.Now I should be able to continue,as this 1 step really had me stumped.Thanks again for your help.This problem is solved.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Smith:
...it finally got me to C:\C JAVA...


Ohhhh... I didn't realize your directory name actually includes the "C" and is literally named "C Java." I thought it was just named "Java" and "C Java" was just shorthand for C:\Java.

I'm glad it's solved!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic