You can put an OSGi service component inside the bundle and in activate method of the service component you can run your java class.
e.g.
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
@Component
@Service
public class MyApplicationStarterService{
@Activate
protected void activate(ComponentContext ctx) {
MyAppClass app = new MyAppClass();
app.run();
}
}