• Post Reply Bookmark Topic Watch Topic
  • New Topic

writing your first java program  RSS feed

 
Ja Flores
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im having trouble compiling and executing the program. When I enter the directory \Program Files\Java\src I get "The system path cannot be identified". Should I save the code in a different directory?
ps Im using windows 7
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should I save the code in a different directory? 

you should create your own folders to hold your code.  Don't mix your stuff in with system or java SE files.
 
Ja Flores
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I compile a program saved in my \Documents\src?
 
Ja Flores
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a successful response when I typed javac -version and java -version into command line, Im not sure if this helps with my question. When I type cd \Documents\src into command line I get the system cannot find the path specified
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you create your own folders for your java files?  Easiest is from the root, not buried in Documents.

Can you copy the contents of the command prompt window and paste it here so we can see exactly what happened?
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.

Many DOS commands like cd  will display help with /?

D:\Testing>cd /?
Displays the name of or changes the current directory.

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

  ..   Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current
directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as
the on disk names.  So CD C:\TEMP would actually set the current
directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
Press any key to continue . . .
 
Ja Flores
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my Java files saved in \C:\Program Files\Java\jdk1.8.0_131

This is the text from my command prompt

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\Jesse>cd \Documents\src
The system cannot find the path specified.

C:\Users\Jesse>
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my Java files saved in \C:\Program Files\Java\jdk1.8.0_131 

I strongly recommend you move all your files out of the java folders.  Create your own folders for your java files.

Have you seen the tutorial:  http://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ricky Spanish wrote:I got a successful response when I typed javac -version and java -version into command line, Im not sure if this helps with my question. . . .
Yes, it does help, thank you. It shows that you have correctly installed Java®/the JDK. If you exclude problem A, we know we don't have to worry about it and can devote more attention to the real problem.
NR is correct that you shou‍ld make your own folder. What I usually suggest is that you pass this instruction (or replace “java” with whichever name you want for your folder) immediately after opening a terminal/command line:-
mkdir java
You only need to do that once per computer. Follow it with
cd java
whenever you open a new terminal/command line. Both instructions will work exactly the same on Windows® and Linux boxes (probably Macs too, but I am not sure).
The reason you got a “cannot find path” error may be because that directory doesn't exist, or its name is spelt wrongly.

And . . . welcome to the Ranch
 
Ja Flores
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome thank you so much I was able to write my first java program... thanks for the warm welcome
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!