Solved

Temporary Override changes

Posted on 2006-12-01
10
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 300 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 50 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 150 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
Independent Software Vendors: 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse buid path vs tomcat lib path 10 38
String array comparison 4 46
jboss 7.1 start up error 1 63
Tagging and Merging on Branch 1 43
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

733 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