Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jar files

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My directory structure is ..
c://.../jdk/bin/programs

When i create a jar file of (say) a.class and b.class which is in programs directory. The jar file is created in the bin directory.
because the jar.exe is in bin ,it is created there.

I want that *.jar to be created in programs dir.
Is it possible??. If so how..
I tried -C option but ended up with error.
So help me out .
Thanks
 
Casttro Francis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James

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..
 
Casttro Francis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the path using


Hope this will help you
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PATH is a dos command .. so if i change that would that effect all other commands path? ?
or would that effect only the next command??
Dont mind if it sound stupid :roll:
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explanation...
I tried the following

path C:\Program Files\Java\jdk1.6.0_03\bin\programs
jar -cf jms.jar programs/pack1

with the jdk/bin as as current directory

Still it created the jar file in bin..
What is that i am doing wrong
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 50246
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea to put your own files in the bin directory. Better to move that folder elsewhere.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Casttro Francis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

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..
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Casttro Francis

Thank you so much for helping me... it worked perfectly.
Can you tell me ,what exactly does the PATH command do( or tell).
 
Casttro Francis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Hope this will help you out...
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay... now i understood that.....
To check my understanding...
if i have a fun.exe file which can exectue the command "funny", in the dir
d:\test\fun.exe

and if i am in E:\document\

and if i set the path varible to d:\test\
i can exectue that funny command from E:\document\
 
Casttro Francis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly !! Not only in E:/documents. You can call it from any directory
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah yeah , i just took a example of E:

And thank you so much again .Now Every thing is crystal clear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic