• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running Java Command LIne

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok so I posted earlier and maybe I am missing something w/ running a java program from the command line. Here is the path I have in the command line "C:\Program Files (x86)\Java\jdk1.6.0_14\bin"
Where do I save the .java files, I have read through a couple tutorials and maybe I just dont get it. I appreciate any help as I have searched and searched and cannot seem to get it.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You put the .java (the source code files) in a package/directory hierarchy, wherever you want.
 
Mark Nibert
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that is where I am confused when I run javac <programname> and I am in the bin file how does it know where the compiler is? I am not following how to do it at all.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You put the .java (the source code files) in a package/directory hierarchy, wherever you want


I would not recommend to put them under C:\Program Files (x86)\Java\jdk1.6.0_14\bin

I suggest you to make a new directory somewhere. For example, C:\java\src. If your source is in a package, make new directories under C:\java\src. For example :

You would put this class here : C:\java\src\sample\MarkNibert.java
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

how does it know where the compiler is?


I see your are using Windows. Windows uses special environment variables to hold certain information. There's one called PATH. It holds directories. If you type a command at the command line, these directories will be scanned to find the command. Try to type SET at the command line. You'll see PATH in the list. C:\Program Files (x86)\Java\jdk1.6.0_14\bin must be in there.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, a good place to start is here.
 
Mark Nibert
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am feeling pretty retarded. I am not able to get it to work. I created c:\java\src and the folder I have my application in is chap11 so the full path is c:\java\src\chap11 here is the code



When I run the code while in the c:\java\src directory or the c:\java\src\chap11 directory it returns an error

'javac' is not recognized as an internal or external command, operable program or batch file

So I retyped it out w/ the full path to the javac and it still doesnt work. I am on windows 7 and eclipse works so I think I have the right jdk installed.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

'javac' is not recognized as an internal or external command, operable program or batch file


Which means that your sdk bin directory is not in the PATH. Check this page which tells you how to edit the PATH in Vista. Edit it, and add "C:\Program Files (x86)\Java\jdk1.6.0_14\bin". Make it the first directory in the PATH.
 
Mark Nibert
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok that worked so it knows where the compiler is. It is now working, thanks a million for putting up w/ my ignorance.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lots of people have that problem; setting the PATH is very confusing until you have done it a few times.
 
Mark Nibert
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah it seems easy looking back but last night I was ready to rip my hair out. I appreciate the help. I really enjoy these forums, everyone is so helpful. I wish I had the money to do the 200 dollar class.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic