0

Basically I want to replace the Canvas class at runtime by an application that uses my custom Canvas class, I heard xbooting can do this but there are no tutorials or anything.

So I'm just wondering what the vm arguments are, can you help me please?

Charles Menguy
  • 40,830
  • 17
  • 95
  • 117
Francis Malloch
  • 1,074
  • 9
  • 20
  • 4
    *"uses my custom Canvas class"* DYM a `java.awt.Canvas`? Time to join us in the 3rd millennium & use Swing. BTW 1) What is the use-case here for a) Extending this class. b) Using it instead of the inbuilt class? 2) It will not be legal to distribute this app. AFAIU. – Andrew Thompson Jan 10 '13 at 03:34
  • 2
    @AndrewThompson - My understanding is that it would not be legal to distribute a JVM that had the custom class instead of the standard one. However, distributing the class together instructions on how to modify the bootclasspath would be OK. (Doesn't make it a good idea though ...) – Stephen C Jan 10 '13 at 05:20
  • @StephenC Thanks for clarifying. Your suggestion makes more sense. – Andrew Thompson Jan 10 '13 at 05:22
  • BTW -1 for ignoring my questions. They were intended to help you arrive at the best solution. – Andrew Thompson Jan 10 '13 at 05:24
  • @AndrewThompson I think that Francis should have answered your questions although I do not think they are relevant to the original problem and thus the downvote is not deserved. The problem is simple - how to setup a bootclasspath, that does not need to be justified by a usecase. Plus, as StephenC already pointed out, its perfectly legal to write/distribute such apps. Thank you. – Aleš Jan 10 '13 at 18:31

1 Answers1

3

By xboooting you probably mean the -Xbootclasspath parameter?

You can use the -Xbootclasspath to override the classes that are being loaded when the VM is booting. This way you can give the VM your own implementation of a certain class and it will be used right from the start of the VM. You can do something like this:

java -Xbootclasspath/p:path_to_the_jar_with_myCanvas_class.jar HelloWorld.class

But the -Xbootclasspath won't replace the Canvas class at runtime, the replacement will occur already at the start of the VM.

Here is a nice post about Xbootclasspath : When to use -Xbootclasspath on HotSpot?

Aleš
  • 8,896
  • 8
  • 62
  • 107