hi

i have a problem with my java program.i can compile and run the java program if i keep them in jdk\bin folder, but i can only compile and can not run if i kept the java program in any other location. can anyone tell me where i'm doing wrong. sorry for cery bad english

Could you post the command you are using to compile your program when it is in the jdk\bin folder?

Well, which version of jdk do you have? Which IDE (Integrated Development Environment) are you using? Dr. Java or NetBeans or..?
I use jdk1.5 and 1.6, edit programs in Notepad++ and run them in command prompt. So, the way I run java files saved in some other location is as follows:
in the Command Prompt, go to the folder where your java file is saved.
like... Start --> Run --> Type 'cmd' and press enter --> cd<space><directory name> takes you to the directory you type after space.
Like for going to a folder 'Example' in drive D:\, type '
D:\
and then cd Example
Now there would be something like D:\Example>_
here you'd have to set path in the EXACT following way: (don't add even spaces).
set path="C:\Program Files\Java\jdk1.5.0_11\bin"

I think this is the problem that you're not setting the correct path in the command prompt or in the IDE settings or wherever.
Now, once you've set the path as mentioned above,
javac <filename>.java is the way to compile and
java <filename> is the way to run.

I hope you know that you need to do something in the main method, like calling the functions you've written or printing something. Only then you'd be able to see some visual proof that the program is running. :-)
I hope I helped.

P.S.: Apologies for making the post too lengthy. I realise I'm a little too verbose. Sorry for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.