• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Getting Classpath at runtime  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have tried all different ways(that I can think of ;( ) to solve the current problem, but was not successful. Here is the problem, Please help.

I have writtten a java program, that is kicked off through a shell script to update bunch of tables. So I have a props file that has the database password and other information to connect to the database. So in the program I said:

ConnFile.load( Runtime.getRuntime().getClass().getResourceAsStream( p_propsFile ) );

where p_propsFile is the file with Db connection information.

But I am having problems getting connection to the db using hte above command. I am getting NUll POinter Exception on this line, which tells me that it is not able to locate p_propsFile. I also tried used ClassLoader.getSystemResourceAsStream().
One thing I am sure is that this location is in the Websphere classpath..

I have the class files and props files at different places, so I need to use a command to look into the Webpsphere classpath for locating the files(props file in teh current case).

PLease help me .
Thanks,
Sue
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at your topic, the answer is
String classpath = System.getProperty("java.class.path") though you should have a very obscure reason for doing this.

Otherwise, show which version of WebSphere; and how you claim to have placed the file in the CLASSPATH; also give the String value of the resource that you are trying to obtain.

I'm assuming you have (tried to) put the resource in the WAS global classpath, otherwise, there might be a class loader issue (but this is less likely).

More info.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't work when developing code in Eclipse but it might if the jar/class is run from a command line or script..
This is what was returned to me:

/home/programmer/development/WorkspaceAirborne/airborne.tools/bin:/home/programmer/development/WorkspaceAirborne/airborne.etc/bin:/home/programmer/development/WorkspaceAirborne/airborne.io/bin:/home/programmer/development/WorkspaceAirborne/airborne.common/bin:/home/programmer/development/WorkspaceAirborne/airborne.containers/bin:/home/programmer/development/WorkspaceAirborne/airborne.image/bin:/home/programmer/development/WorkspaceAirborne/airborne.localEnvironment/bin
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless she is very determined, after nearly eight years I imagine the OP has stopped worrying about the problem.
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Unless she is very determined, after nearly eight years I imagine the OP has stopped worrying about the problem.



Quite true, but I found the post when searching for information and others may as well so I thought I would comment.

BTW in Ubuntu Indigo and Open JDK there is no $CLASSPATH variable.
 
Marshal
Posts: 60829
190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We used to worry dreadfully about people reopening old posts, but if you look at the link, you will see we have changed our tune and are usually happy to have old posts answered.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!