0

I want to make a basic BlackBerry program that when opened executes a line of code.

When I make it with a basic "Hello World" UI it works fine, but when I just have the line of code with no UI, I get "Uncaught exception: no Application instance"

From my testing this leads me to believe the OS needs something to tell it that the application has been instantiated and can deliver code.

How can I make a program without an UI that when run from a app icon press will open and be able to deliver the code?

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Dave
  • 477
  • 2
  • 5
  • 18
  • have u tried autorun on startup and system module option for background apps.If an app extends from Application it is accompanied with many options like "autorun on startup" or "system module". or can u explain ur problem if am telling u wrong – Swati Jan 10 '11 at 11:10

2 Answers2

2

try this

import net.rim.device.api.system.Application;


public class Sample extends Application{

    public static void main(String[] args) {

        System.out.println("Application with no UI");
    }


}
Vivart
  • 14,900
  • 6
  • 36
  • 74
  • It doesn't run my code though. I have a simple HelloWorld one with one additional line of code after the screen gets made and in that the code executes. With this example above, I add my line of code after System.out.println("Application with no UI"); and the app doesn't run it. – Dave Jan 07 '11 at 14:48
  • I also tried replacing your: System.out.println("Application with no UI"); with my line and I still get the Uncaught exception: no Application instance error. Even when I keep your line and add my line after it. – Dave Jan 07 '11 at 16:07
0

You need to add your application to the Event Dispatcher:


public class SomeApp extends Application {

    public static void main(String[] args) {
        new SomeApp ().enterEventDispatcher();
    }

    public SomeApp () {
        System.out.println("HelloWorld!");
    }
}
Jonathan Fisher
  • 380
  • 1
  • 5