I guess you were executing the command from /jdk/bin directory.. First set the class path and then execute the above command to make jar from programs directory. It will create the myfile.jar in the programs directory..
Any fool can write code that a computer can understand. Good programmers write code that humans can understand....
If you set it in a command window, it will affect only the PATH for that command window and that session. It will not affect other command windows or shells (such as Windows Explorer which is the primary Windows GUI). If you add it to your environment variables settings, than it will be present for all command windows opened after its been set.
There is nothing wrong with setting it permanently. It won't break other commands (if done correctly). And if you are going to be doing regular Java development, it will make your life a lot easier if you put it in your path permanently. In Windows, you can do this by going into the System control Panel applet, go to the Advanced tab, click Environment Variables, and edit the PATH system variable and append it. Once you click OK on all the windows, it will be in your PATH for any new command windows you open (but not for any that are already open).
You're creating a file in your current working directory. Changing the PATH environment variable doesn't have any effect on what your current working directory is. To change that, you use the CD command. [ December 07, 2008: Message edited by: Paul Clapham ]
I totally understand that its a bad idea to keep file in bin... But i was trying to create a jar file(destiny) in some other folder other than in jdk/bin. Which i was not able to. And that is what i was looking for .
Joined: Oct 08, 2008
Create a new directory called programs under c: and store the .java or .class files. Now open a command prompt then set the path as
Now change the prompt to your working directory, Ex: c:/programs. Now execute
This will create the jar file in the working directory itself..
Thank you so much for helping me... it worked perfectly. Can you tell me ,what exactly does the PATH command do( or tell).
Joined: Oct 08, 2008
The PATH variable contains directories where binary files (e.g. EXE files in Windows) will be looked for. If you open a command prompt and type "javac", you're supposed to have the "bin" directory of your sdk into the PATH, otherwise you'll get an infamous "Command not found" error message.
The CLASSPATH contains directories (or JAR files), from where your java compiler/runtime will look for .class files (and some others). For example, "java Hello.class" will not work unless you set the directory (or JAR file) Hello.class is in, into your CLASSPATH.
PATH : The OS will look into this while executing. CLASSPATH : The Application will look into this while executing.