Solved

Temporary Override changes

Posted on 2006-12-01
10
165 Views
Last Modified: 2010-03-31
Is there a way to setup a directory in the classpath, so that any jar files in that directory are looked at.  Or do we have to list each jar file individually.  

If I coluld setup a directory I would add d:\logs\abc\templib to the beginning of the classpath for all app/db/hst servers.  If I have to do it individually I would like to add d:\logs\abc\templib\ArcTemp.jar at the beginning of the classpath.  

What I would like to be able to do is if there's a problem in a program like our Analyzer, we could export the fix to ArcTemp.jar instead of ArcAnalyzer.jar and put that file in the \logs\aul\templib.  This would allow the new code to work until we go through the process of creating tickets and getting it deployed to our production libarary.
0
Comment
Question by:TheVeee
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 300 total points
Comment Utility
> Or do we have to list each jar file individually

I am afraid you will have to list each jar file individually, except if you write your own classloader which looks automatically in all jar files that can be found inside folders that are in the classpath.
0
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 50 total points
Comment Utility
You could also leave your CLASSPATH unchanged and put the .jar's in the 'lib\ext' of the JAVA distribution:

on my PC that would be : C:\Program Files\Java\jre1.5.0_09\lib\ext\

;JOOP!
0
 
LVL 12

Assisted Solution

by:enachemc
enachemc earned 150 total points
Comment Utility
Are you trying to load classes at runtime that are not in the initial classpath of your application? If that is so, you should use custom class loaders.
0
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
The 'lib\ext' of the JAVA distribution is 'always' in the classpath of the application.

;JOOP!
0
 
LVL 5

Author Comment

by:TheVeee
Comment Utility
Well kind of...

Basically we want a temp overide library... so for example we have a class say like "CheckThis.java" and we first migrate it to production.  

Now it running and we have a problem within it..

We now want a way to move a temporary fix to a temp library and when the application is running notice its has a new copy in the temp directory with the fix and begin using this until we go through the procedures of moving it to a production.  

So basically its a emergency fix solution....
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 12

Expert Comment

by:enachemc
Comment Utility
you cannot realy do that. If a class has been loaded, it will not be reloaded by the same class loader. In order to changed the implementation of a class at runtime, you must use custom class loaders. If your class is loaded by the app class loader, you're stuck with it.

You will have to be very very carefuly if you delve into this. If you have two definitions for a class, you will not be able to use one in place of the other. They will not be seen by the compiler as being the same class, though they have the same class name. Classes are compared by java by their refference (==), not by using the equals function.
0
 
LVL 5

Author Comment

by:TheVeee
Comment Utility
So is there a way to say instead we stop the the application and then it sees the class in the temp class file and uses that one instead of the existing one?

So this would be more like a override area, so when the classloader starts it first checks library a, and if it there it compiles that code, and bypasses not compling the current production class.... so in theory their would only be one class created...
0
 
LVL 12

Expert Comment

by:enachemc
Comment Utility
yes, there is a way. But it is dangerous (to be read: it should be handled with much care). If you do things right, you will have no problems. The main thing that increases complexity is the number of entry points in the jar(s). If there would be only one entry point (one class that knows itself about the others in the same jar), things would be quite easy.

So, instead of loading the classes from the app class loader, load them in a custom class loader, and use them. When you want to change classes, load the new classes and loose ANY reference to the old classes. If you keep references to the old classes together with the new ones, you could find yourself in quick sands.
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
> So is there a way to say instead we stop the the application and then it sees the class in the temp class file and uses that one instead of the existing one?

You will have to write your own classloader that will first be checking the temp folder. If the class is there then it will be loaded otherwise the application classloader will load it from the usual location.
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
:)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now