• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Code not working thru command prompt

 
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I know its kinda lame question, but I am not able to run any java code thru the console i.e, CMD. I have tried searching online and the forums for this issue but those solutions are not helping me. I don't know what I am doing wrong.
I have java compiler installed at C:\Program Files\Java\jdk1.7.0_02\bin
I have my Java files at D:\Game, folder has 3 java files.

The error that I get is "javac" is not recognized as an internal or external command. ( )
http://www.skylit.com/javamethods/faqs/javaindos.html is the link, which I referred to compile the file, but that did not help.

Kindly guide me Kind Sir/Mam. I am stuck on this for quite sometime.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish L. Sharma wrote:
The error that I get is "javac" is not recognized as an internal or external command. ( )



You need to set your PATH environment variable to include the bin directory where the javac executable lives. The command shell uses PATH to search for executables matching the name you type. I thought we had a FAQ on this site for that but I can't seem to find it. I'm sure if you google for something like how to set Windows PATH variable you'll find plenty of resources giving you the details.
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the link you provided, if javac can't be found check your PATH variable. If you set it, maybe you made an error in syntax. Check there first to make sure your variable setting is correct, has no space between variables, etc
 
Ashish L. Sharma
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:

Ashish L. Sharma wrote:
The error that I get is "javac" is not recognized as an internal or external command. ( )



You need to set your PATH environment variable to include the bin directory where the javac executable lives. The command shell uses PATH to search for executables matching the name you type. I thought we had a FAQ on this site for that but I can't seem to find it. I'm sure if you google for something like how to set Windows PATH variable you'll find plenty of resources giving you the details.



Thanks a lot. I'll try and would let you know!
 
Ashish L. Sharma
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carol Murphy wrote:According to the link you provided, if javac can't be found check your PATH variable. If you set it, maybe you made an error in syntax. Check there first to make sure your variable setting is correct, has no space between variables, etc



i'll check it and would let you know if that solves the issue!
 
Ashish L. Sharma
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish L. Sharma wrote:

Carol Murphy wrote:According to the link you provided, if javac can't be found check your PATH variable. If you set it, maybe you made an error in syntax. Check there first to make sure your variable setting is correct, has no space between variables, etc



i'll check it and would let you know if that solves the issue!



Thanks for the help Carol, I tried using the PATH command and made sure that there is no typos while entering the path, but still I cannot get it to run my code. If you want I can paste the screenshots, if that help?
 
Ashish L. Sharma
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:

Ashish L. Sharma wrote:
The error that I get is "javac" is not recognized as an internal or external command. ( )



You need to set your PATH environment variable to include the bin directory where the javac executable lives. The command shell uses PATH to search for executables matching the name you type. I thought we had a FAQ on this site for that but I can't seem to find it. I'm sure if you google for something like how to set Windows PATH variable you'll find plenty of resources giving you the details.



Hi Jeff,
Thank you for the help. After setting up the CLASSPATH using the environment var helped. I am able to compile the code perfectly. Thanks a lot!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish L. Sharma wrote:
Thanks for the help Carol, I tried using the PATH command and made sure that there is no typos while entering the path, but still I cannot get it to run my code. If you want I can paste the screenshots, if that help?



No screenshots please. Describe the exact steps you followed, and copy/paste the exact commands you entered and the exact results you got.

Note that if you set the PATH variable in the Control Panel, you'll need to start a new command prompt. The one that's already open won't see changes made after it starts up.
 
Ashish L. Sharma
Greenhorn
Posts: 16
Android Eclipse IDE C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish L. Sharma wrote:

Ashish L. Sharma wrote:

Carol Murphy wrote:According to the link you provided, if javac can't be found check your PATH variable. If you set it, maybe you made an error in syntax. Check there first to make sure your variable setting is correct, has no space between variables, etc



i'll check it and would let you know if that solves the issue!



Thanks for the help Carol, I tried using the PATH command and made sure that there is no typos while entering the path, but still I cannot get it to run my code. If you want I can paste the screenshots, if that help?



Hi Carol,
Setting up the Environment variable for CMD helped. Thanks for pointing me to the right direction. God Bless you both!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish L. Sharma wrote:

Jeff Verdegan wrote:

Ashish L. Sharma wrote:
The error that I get is "javac" is not recognized as an internal or external command. ( )



You need to set your PATH environment variable to include the bin directory where the javac executable lives. The command shell uses PATH to search for executables matching the name you type. I thought we had a FAQ on this site for that but I can't seem to find it. I'm sure if you google for something like how to set Windows PATH variable you'll find plenty of resources giving you the details.



Hi Jeff,
Thank you for the help. After setting up the CLASSPATH using the environment var helped. I am able to compile the code perfectly. Thanks a lot!



No, no no.

I said PATH, not CLASSPATH. The CLASSPATH environment variable has nothing to do with the error you reported.

PATH is what the command shell uses to find the executable you're invoking, such as java.exe or Notepad.exe. Since you didn't have the Java bin directory on your PATH, when you typed javac the command shell couldn't find the javac executable.

CLASSPATH is one of the ways the JVM knows where to look for .class files once it's up and running. You really shouldn't even set this variable. It will become a nuisance down the line. Instead just use the -cp or -classpath argument on the command line.
 
Marshal
Posts: 80097
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a “first program” FAQ which may help you.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This error arises because we have not set JDK path in computer path variables. So you must change the path variables in order to compile the java program. If you didn't know how to change variables then check this post
 
Campbell Ritchie
Marshal
Posts: 80097
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JD:welcome to the Ranch

If you are only here to promote your website, please contact Paul Wheaton about paying for the advertisement.
 
Get out of my mind! Look! A tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic