• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting up the PATH environment  RSS feed

 
Jane Sampson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad nothing is too simple for this forum as I am struggling with this.  I have started a little coding in some IDE's but need to start doing it on a text editor for my college course which starts soon.  I thought I had changed the path variable but the command prompt still defaults to where it always did.  I have Windows 10, have saved a Notepad java file as .java and .class and put them in a Java folder in my Documents.

Where am I going wrong, and I would be so grateful for any really basic advice here!  I was OK using IDE's...Thanks in advance.
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't matter where you have saved the file.  But does your path environment variable points to java_home\bin? For example


C:\Program Files\Java\jdk1.8.0_121\bin

and what is your exact issue?  Default command prompt or program compilation?
 
Jane Sampson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the reply.  My environment variable says: C:\Program Files (x86)\Java\jdk1.8.0_131\bin  But when I open the command prompt is says C:\Users etc.  And I don't actually know how I would go about running a program.  I think you type % javac at the command line but it just says not recognised.
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you don't seem to have any java related problem.  What you wish to do is to change the default command prompt location.  But why do want that?  You can always change that from command prompt itself.  For example it shows the default path



C:\Users\Admin>

and I wish to go to a directory called myfolder I can use the command cd \myolder and it will change the prompt to

c:\myfolder>

Your problem is not related to java it's how a change a directory from command prompt.
 
Jane Sampson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that.  Yes, I can change directory to where I store the files, but how do I run them?  I do realise it's not a Java problem but it's stopping me getting on at the moment.  Thanks so much for your help.
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you need to compile it and then run it.  Command to compile is javac and to run is java.  For example I have a file called Prog1.java


c:\my folder>javac Prog1.java

this will compile the code and generate the .class file.

next is to run the program

c:\my folder>java Prog1
 
Jane Sampson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swastik

That worked!  Thank you so much!! All this hunting around for ages and I just come across you and you solved it just like that.  Simple really.  Thanks again for making my day!!
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!