• Post Reply Bookmark Topic Watch Topic
  • New Topic

Change of System class  RSS feed

 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to change a system class and I also want that changes to be reflected in my program Actuall What I have done is as we all know that java/jre/lib/rt.jar contains the actual system class for acccess. Now I want to change the System.java file that whenever we want to exit by calling System.exit() method There should be a statement about the author. I know this is not at all important but this will help in those projects which want to change some algorithms and then prescribed to SUN to change them. Thats why I am asking this question::: I am also enclosing the function which I want to change in System.java Class(In java.lang package).Please do help me because I want to further change the algorithm in Classes which implements List Interface.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first, don't do this. Why not use Runtime.addShutdownHook() instead? This is the proper way to schedule code to run when the VM is shut down.

Second, if you really need to replace a system class, you just have to put that class on the "bootclasspath" using the -Xbootclasspath/p: switch. But as I said, don't do it.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me the procedure for doing this as u advised for bootpathclass
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-Xbootclasspath/p: is a command-line switch to the java.exe program. The argument it takes is the same as -classpath uses. Use "java -X" to get a little bit of help for this option.

But as I said: don't do it for this reason, it's silly. Just use a shutdown hook. Why make your program nonportable and dependent on being launched with certain options, when you can just use a small amount of legal, portable Java code?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!