title: How to get the binary name of a java class, if one has only the fully qualified name?
body: <p>The reflection classes and methods as well as class loaders etc. need the so called "binary" names of classes to work with.</p>
  
  <p>The question is, how does one get the binary name if one only has the fully qualified name, i.e. the name that one would use in source code.</p>
  
  <p>For example:</p>
  
  <pre><code>package frege;
  public static class RT {
      ....
      public static class X { .... }
  }
  </code></pre>
  
  <p>The fully qualified name of the class would be <code>frege.RT.X</code>. Yet, to get the class object, one needs to write:</p>
  
  <pre><code>Class.forName("frege.RT$X")
  </code></pre>
  
  <p>and not</p>
  
  <pre><code>Class.forName("frege.RT.X")    // fails with ClassNotFoundException
  </code></pre>
  
  <p>because <code>X</code> happens to be an inner class of <code>frege.RT</code>.</p>
  
  <p>A possible, but clumsy, solution would be to replace <code>.</code> with <code>$</code> from backwards, one by one, until <code>Class.forName()</code> doesn't throw <code>ClassNotFoundException</code> anymore or there are no more <code>.</code> to replace.</p>
  
  <p>Is there any better/well known/standard solution? I looked in the API docs for <code>Class</code>, <code>CLassLoader</code> and <code>java.lang.reflect</code> but did not find anything usable.</p>