• Post Reply Bookmark Topic Watch Topic
  • New Topic

compiling the first program  RSS feed

 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello "the ranch"
i can't bypass compiling the "my first java progrom. ie MooseGreetings.java

please improve my skills; regards.
java.PNG
[Thumbnail for java.PNG]
thats my screen view of the file. created by notepad
cmd.PNG
[Thumbnail for cmd.PNG]
thats what i get on the prompt cmd
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't type the path...just type:

javac MooseGreetings.java
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its deep.

i have done so; typed  "javac MooseGreetings.java" without quotes in the cmd prompt. the result is not
consoling enough.
cmd.PNG
[Thumbnail for cmd.PNG]
result on the prompt
 
O Shea
Ranch Hand
Posts: 200
3
Java MySQL Database Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alejandro Rosa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
O Shea wrote:Your jdk path is not set.

No, the system found javac, but javac didn't find the Java file.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[Thumbnail for variable.PNG]
env. variable settings
cmd.PNG
[Thumbnail for cmd.PNG]
executing in the above variables gives me that result
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[Thumbnail for cmd.PNG]
when i run path on the cmd prompt
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read all of the posts before you ask a question. Several people (including me) have already told you how to do this.
 
Alejandro Rosa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[Thumbnail for variable.PNG]
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks on that but
i have checked all the THREE fields; i cant find the double bin\bin...
variable.PNG
[Thumbnail for variable.PNG]
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i change on user variables or system?
because i have %JAVA_HOME% in both fields.
thanks
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably best to change all references as it only takes a few moments to do.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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::
 
Pete Letkeman
Ranch Foreman
Posts: 917
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
patson lawrence
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I now got where to run to. thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!