Forums Register Login

compiling the first program

+Pie Number of slices to send: Send
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]
+Pie Number of slices to send: Send
don't type the path...just type:

javac MooseGreetings.java
+Pie Number of slices to send: Send
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]
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

O Shea wrote:Your jdk path is not set.


No, the system found javac, but javac didn't find the Java file.
+Pie Number of slices to send: Send
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]
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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]
+Pie Number of slices to send: Send
Please read all of the posts before you ask a question. Several people (including me) have already told you how to do this.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

'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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
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]
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
thanks on that but
i have checked all the THREE fields; i cant find the double bin\bin...
variable.PNG
[variable.PNG]
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
i change on user variables or system?
because i have %JAVA_HOME% in both fields.
thanks
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
It's probably best to change all references as it only takes a few moments to do.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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::
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
I now got where to run to. thanks
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3928 times.
Similar Threads
Compile "MooseGreetings.java" Access Denied
Java and the questions of an Greehorn ;)
Error while compiling a program in Java using command prompt
Compiling Trouble
Cant get the 'MooseGreeting.java' to compile
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:26:28.