wood burning stoves 2.0*
The moose likes Java in General and the fly likes How can I get Java Console to operate commands such as compile (javac) or change directory ccd:\) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How can I get Java Console to operate commands such as compile (javac) or change directory ccd:\)" Watch "How can I get Java Console to operate commands such as compile (javac) or change directory ccd:\)" New topic
Author

How can I get Java Console to operate commands such as compile (javac) or change directory ccd:\)

Mary Dawson
Ranch Hand

Joined: Feb 08, 2009
Posts: 36
Dear Programmers,
I am having difficulty in getting my Command Promt to operate, I lost the one I had due to

cleaning of my c drive, whereby I lost it. I reinstalled it, and it is in a folder C:\ Sun ,

but even though I put that to the path set command, it still won't do the cd: change directory

(ie: cd: ) nor the compiler (javac Program name.java) commands, I have keyed in the following,

which I thought ought to point to the javac command which is in the 'bin' folder, but it

doesn't change the ineffectiveness of the Console's command response, incidentally

'MyFirstProgram.java' is a file in a folder called 'Systems Code', and my computer has another

drive, d:\, which I am unable to navigate to, below is what I am getting :-
______________________________________________________________________________________________
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\User>set PATH=c:\Sun\jdk1.4\bin;%PATH%

C:\Documents and Settings\User>cd c:\

C:\>cd c:\Systems Code

C:\Systems Code>javac MyFirstProgram.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Systems Code>

C:\Systems Code>cd d:\

C:\Systems Code>
-----------------------------------------------------------------------------------------------
I don't know if anyone can help me.
Thank you for your help in advance.
Yours
Mary Dawson


A man of words and not of deeds is like a garden full of weeds, and when the weeds begin to grow, its like a garden full of snow, and when the snow begins to fall- its like a bird upon the wall and when the bird begins to fly, its like an eagle in the sky
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

normally in windows, if you want to change the drive, you just type the drive letter and a colon. So just do this:

C:\Systems Code>d:


as to the javac not being recognized...did you look to see if the javac.exe is actually in the c:\Sun\jdk1.4\bin directory?

All the PATH variable does is tell the OS where to look for programs. If it's not there, it can't run. In other words, make sure you really HAVE a javac.exe somewhere, and then make sure your path includes that directory.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mary Dawson
Ranch Hand

Joined: Feb 08, 2009
Posts: 36
Hi,thank you for your assistance,
I enclose returns to my input to the console, I have got the path to javac established and it is compiling.
As you can see I cannot seem to get the console to look at the same file in the same directory in drive D, stating as it does 'Access denied'. That isn't that much of a problem as I can still put programs within the accessible C drive.

-----------------------------------------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\User>C:\Systems Code>d:
Access is denied.

C:\Documents and Settings\User>cd C:\Systems Code

C:\Systems Code>javac MyFirstProgram.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Systems Code>set PATH=C:\Sun\AppServer\jdk\bin;%PATH%

C:\Systems Code>javac MyFirstProgram.java

C:\Systems Code>javac RaceAcceleratorPrototypeone.java
RaceAcceleratorPrototypeone.java:11: not a statement
repeat;
^
1 error

C:\Systems Code>C:\Systems Code>d:
Access is denied.

-----------------------------------------------------------
Also on a different note, program RaceAcceleratorPrototypeone.java won't compile.
Code for this is:-

public class RaceAcceleratorPrototypeone

{

public static void main(String[]args)
{
int counter;
for(counter=1; counter<11; counter ++)
System.out.print(counter + " " );
System.out.println ("\nLoop Finished\n");
repeat;
}
}

I suppose the 'repeat' is a throwback to my induction with Pascal, and its 'repeat/until' statements. All the same I did want this program to go back to the start and output numbers from 1 to 10 ad infinitum, as a basis for other programming constructs. Can you tell me if there is another Java statement I can use to achieve this end ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38492
    
  23
Why have you not set the PATH to your Java installation permanently?
Why are you trying to use that system directory?
There is no such keyword as repeat, so repeat; is incorrect syntax. You can find out about the permissible control flow statements in the Java Tutorials.
Mary Dawson
Ranch Hand

Joined: Feb 08, 2009
Posts: 36
Hi,thankyou for your assistance.
How could I set class path permanently then, please ?
I wanted to see if the console could access the D: drive to see if the cd command was working, but as you see it returned 'access denied' If I could rectify that too, it would put me in the right direction.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38492
    
  23
There are instructions about the PATH in our FAQ, or this Java Tutorials page (note what the first problem it describes is ‍), and the links in that tutorial.

You can test it by writing
set PATH="C:\Program Files\Java\jdk1.7.0_15\bin";%PATH%
or similar at the terminal (that particular syntax only works on a Windows® box), or wherever you installed Java. Start with the drive letter, end with bin. If that works, you know what to add to your PATH permanently.
Mary Dawson
Ranch Hand

Joined: Feb 08, 2009
Posts: 36
Thank you, I see I am going over old territory.Path is now fixed.
I wanted to ask something else but it is a different topic so will start a new thread.
Yours
Mary Dawson
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38492
    
  23
You’re welcome
 
 
subject: How can I get Java Console to operate commands such as compile (javac) or change directory ccd:\)