title: Java, get package name of class from string
body: <p>all I have:</p>
  
  <pre><code>String desiredClass = "MyClass";
  </code></pre>
  
  <p>I want to instantize this class, but this name comes from this string. I know it can be done with:</p>
  
  <pre><code>Class.forName(desiredClass);
  </code></pre>
  
  <p>formula, but this also need the package path from this string (name.space.path.MyClass). I know it can be queried by <code>.getPackage()</code> - but again, it needs a direct class reference, not from a string. It looks a snake has bitten its end :)</p>