[Logo]
Forums Register Login
compiling the first program
hello "the ranch"
i can't bypass compiling the "my first java progrom. ie MooseGreetings.java

please improve my skills; regards.
java.PNG
thats my screen view of the file. created by notepad
[Thumbnail for java.PNG]
cmd.PNG
thats what i get on the prompt cmd
[cmd.PNG]
don't type the path...just type:

javac MooseGreetings.java
its deep.

i have done so; typed  "javac MooseGreetings.java" without quotes in the cmd prompt. the result is not
consoling enough.
cmd.PNG
result on the prompt
[cmd.PNG]
Your jdk path is not set.

Just do following->

1) go to your folder where java is installed (mostly in C/Program files) then go to Java->then jdk-> then bin and then copy the path of current directory.

2) Then just search for environmental variables(in type to search here) and then click on it-> then there below you find path-> there edit-> then new-> and then paste that copied path.->Ok->Ok.

  Now compile the program.
 

patson lawrence wrote:its deep.

i have done so; typed  "javac MooseGreetings.java" without quotes in the cmd prompt. the result is not
consoling enough.



The problem here is that you are not in the right path. Your terminal is in C:\Windows\system32, but MooseGreetings.java is located in C:\java\src.

The solution is to locate the terminal in the cool path, try this:

> cd C:\java\src
> javac MooseGreetings.java
 

O Shea wrote:Your jdk path is not set.


No, the system found javac, but javac didn't find the Java file.
i will never forget my first;

so far this is how the variables field looks like..

apparently the cmd prompt is telling me this (see attached)

thank you.
variable.PNG
env. variable settings
[variable.PNG]
cmd.PNG
executing in the above variables gives me that result
[cmd.PNG]
 

Knute Snortum wrote:

O Shea wrote:Your jdk path is not set.


No, the system found javac, but javac didn't find the Java file.



please direct me on how to locate the terminal from sysyt 32.

thanks.
Use the cd (change directory) command to change to the directory holding the java source file.

To see what the PATH contains, enter the command: PATH
in a command prompt window

To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.
You may have missed Alejandro Rosa's post, which first explained this.

In your first picture above, I can see that your Java file is in C:\java\src.  So the first thing is to change directory (cd) into that directory (also called a folder).

    cd c:\java\src

Now you call compile the file without a path to it.

    javac MooseGreetings.java
 

To see what the PATH contains, enter the command: PATH
in a command prompt window 


The OP's PATH seems to be okay.  Notice that the error message is from javac and that it prints the usage underneath.
 

Alejandro Rosa wrote:

patson lawrence wrote:its deep.

i have done so; typed  "javac MooseGreetings.java" without quotes in the cmd prompt. the result is not
consoling enough.



The problem here is that you are not in the right path. Your terminal is in C:\Windows\system32, but MooseGreetings.java is located in C:\java\src.

The solution is to locate the terminal in the cool path, try this:

> cd C:\java\src
> javac MooseGreetings.java



Hello; please guide me changing to path of my file. how to remove that windows/syst 32 path.
 

Knute Snortum wrote:

To see what the PATH contains, enter the command: PATH
in a command prompt window 


The OP's PATH seems to be okay.  Notice that the error message is from javac and that it prints the usage underneath.



this is my current path;
cmd.PNG
when i run path on the cmd prompt
[cmd.PNG]
Please read all of the posts before you ask a question. Several people (including me) have already told you how to do this.
 

patson lawrence wrote:

Knute Snortum wrote:

To see what the PATH contains, enter the command: PATH
in a command prompt window 


The OP's PATH seems to be okay.  Notice that the error message is from javac and that it prints the usage underneath.



this is my current path;



Write cd C:\src\java in the terminal.
Please copy the contents of the command prompt window and paste it here.  Images are no good because text can't be copied from an image to include in a response.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd C:\java\src

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

C:\java\src>


the above is my result. not any easy
 

'javac' is not recognized as an internal or external command,


Double Check that the PATH has the correct value.   Look at the value shown in the command prompt window when the PATH command was entered.
Okay, I was wrong.  Your JAVA_HOME environment variable may not be set correctly.  At the command prompt, type:

    echo %JAVA_HOME%

Copy and paste the output here.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_144\bin

C:\Windows\system32>

and beofre i forget, i now know how to copy from cmd prompt. thank you.
Looking at the screen shot of the PATH output, the path does not seem to be correct.

Path=C:\Program Files\Java\jdk1\8.0_144\bin\bin

There appears to be one too many "bin"s in the path. The path should point to the directory where javac is located.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>path
PATH=C:\Program Files\Java\jdk1.8.0_144\bin\bin;C:\ProgramData\Oracle\Java\javap
ath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\
WindowsPowerShell\v1.0\

C:\Windows\system32>


thats true; i can notice _144\bin\bin;
screen shot on variable settings attached
variable.PNG
[variable.PNG]
So if you remove the extra "bin" does you get and better/different results?

You may have to close the command prompt and open up a new one for the change to take affect.
thanks on that but
i have checked all the THREE fields; i cant find the double bin\bin...
variable.PNG
[variable.PNG]
I have

echo %JAVA_HOME%
C:\Program Files\Java\jre1.8.0_131\

You have

echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_144\bin

What if you change your JAVA_HOME value to remove the bin so that is looks like mine?
i change on user variables or system?
because i have %JAVA_HOME% in both fields.
thanks
As soon as you update %JAVA_HOME% and remove "bin" all places that use that will be updated, you still may need to close the command prompt and open a new one.
It's probably best to change all references as it only takes a few moments to do.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>path
PATH=C:\Program Files\Java\jdk1.8.0_144\bin;C:\ProgramData\Oracle\Java\javapath;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Wind
owsPowerShell\v1.0\

C:\Windows\system32>

path looks like this after removind the \bins on all the fields. thanks.. and then now am moving onto the

> cd C:\java\src
> javac MooseGreetings.java
CONGS!!!
thank you so much;

i appreciate the persistence; big ups.

in that folder i have now 5 files. am sure thats what i need to keep on track.

appreciated::
Well I'm glad that you got this working and now you can get onto the "fun" and the "hard" parts with programming in Java.
I now got where to run to. thanks
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 3420 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 21, 2018 00:03:04.