title: Get all declared subclasses at runtime in Java?
body: <p>Let's say I have a package that contains all subclasses of 'Device', like this one:</p>
  
  <pre><code>class TV extends Device{
  
     @override
     public void run() {
         //code goes here
     }
  
     private void moreMethods(String args){
         // more code
     }
  </code></pre>
  
  <p>}</p>
  
  <p>In the main class it should be possible to instantiate and run every subclass of Device at runtime by calling everyone's 'run' method.</p>
  
  <p>The benefit of this is to allow users to simply put new Device files into the package and said files will run automatically without having to edit the main class.</p>
  
  <p>Is there a clean way to do this? I was thinking that maybe if I had a txt file in that package with every subclass name, it would be possible. Minor inconvenience being the user had to edit the file and add the new device's name.  </p>
  
  <p>Is there another way to achieve the same result? I'm interested in providing a way for users to add new device files without editing existent code.</p>