aspose file tools*
The moose likes Beginning Java and the fly likes setting classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting classpath" Watch "setting classpath" New topic
Author

setting classpath

Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71

Hello Everyone,

I have resource-bundle in my server and a runnable jar file using this resource-bundle, I want to set the path for it. how to do this? please help.

thanks & regards
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11494
    
  16

Your subject says 'classpath', but your post says 'path'. These are two VERY different things.

the process to set either is the same, but you should be sure of which you need first.

My final comment is "How to set it depends on what operating system you are using".


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71


Thanks for reminding me, I actually want to set path on linux operating system, the resource-bundle is outside of my jar, how to do that.

thanks & regards
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11494
    
  16

well it would depend on what shell you are using. a quick google search shows this:

For bash shell:
export PATH=$PATH:/usr/sbin/:/usr/local/bin
For tcsh or csh:
set PATH = ($PATH /usr/sbin /usr/local/bin)


That will let you set it in your current session. that basically says "set the PATH variable to what it currently is plus these two new directories."

if you want a more permanent change to it, you will probably have to edit your profile. in the tsch, it should be in your home directory, and is called '.cshrc'. There should be something similar for bash and other shells.
Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

if you want to set the class path, then this is the band programming , if you want to use the jar packages , you just specified at command with with the help of -cp switch. if you want to the the path only then foloow the above answer.


With Regards :-
Harmeet Singh
Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71

Thanks,

But it is not working, I have a Resource.Cofig.properties file and a jar file. In jar file classes are using this resource file using ResourceBundle.getBundle("Resource.Cofig"), Now this properties file is not inside jar file, it is on the server at location /usr/emtize/ with its package structure. I want to run this jar (Runnable jar). How to do this.

I donot want to chage code.

Thanks & Regards
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
when you use java -jar MyApp.jar, the jar's own classpath settings defined by its manifest file will override anything on the command line that is defined by the cp option. The cp option is worthless for setting a classpath in this situation.

Source - Discovering Resourcebundles
Sudhakar Sharma
Ranch Hand

Joined: Apr 04, 2009
Posts: 71

thank you, class-path entry in menifest file resolve my problem. thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting classpath