?
Solved

Temporary Override changes

Posted on 2006-12-01
10
Medium Priority
?
173 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 1200 total points
ID: 18053530
> 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 200 total points
ID: 18054029
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 600 total points
ID: 18054318
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

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

;JOOP!
0
 
LVL 5

Author Comment

by:TheVeee
ID: 18054359
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
 
LVL 12

Expert Comment

by:enachemc
ID: 18054453
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
ID: 18054757
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
ID: 18059639
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
ID: 18060026
> 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
ID: 18068453
:)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

839 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