• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mary Dawson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mary Dawson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You’re welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic