Public Shared Sub main

I'm working on java for the last 6 months... But I'm still confused public Shared Sub main (args [] method) of channels.
Can anyone suggest this topic in a practical and detailed way? It would be appreciated :-)

Manon says:
I read that the JVM is responsible for loading the class who knows the 'main' method (the program entry point). Right?
If this is the case, then when we use private or protected instead of public, why he gives runtime error? While I think that it must produce the error in compiling.

As regards to Java language is, main() is just another method like any other. There is nothing special about this. Is the Java runtime that exactly looking for public Shared Sub main (String []). The language and the compiler do not know or care anything on this subject.

Tags: Java

Similar Questions

  • Is there a public api Api to check that the cursor is open or close for blackberry 6.0?

    Hi all

    is there an api to check the slider is open or close for Blackberry JDE 6.0.

    Thank you

    Navneet Gupta.

    Hi you

    First of all "accept the solution please...." »

    See this link for more information...

    http://www.BlackBerry.com/developers/docs/4.6.0api/NET/rim/device/API/system/sensor.html

    Net.rim.device.api.system import. *;
    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.RichTextField;
    Import net.rim.device.api.ui.container.MainScreen;

    SerializableAttribute public class SensorDemo extends UiApplication
    {
    public SensorDemo()
    {
    Screen SensorDemoScreen = new SensorDemoScreen();
    pushScreen (screen);
    }
    Public Shared Sub main (String [] args)
    {
    SensorDemo app = new SensorDemo();
    app.enterEventDispatcher ();
    }
    class SensorDemoScreen extends screen implements the SensorListener
    {
    private RichTextField statusField1;
    private RichTextField statusField2;

    public SensorDemoScreen()
    {
    setTitle ("sensor Demo");
    statusField1 = new RichTextField();
    statusField2 = new RichTextField();
    Add (statusField1);
    Add (statusField2);

    Check for the presence of a sensor
    Boolean hasFlipSensor, hasHolsterSensor, hasSliderSensor;
    hasFlipSensor = Sensor.isSupported (Sensor.FLIP);
    hasHolsterSensor = Sensor.isSupported (Sensor.HOLSTER);
    hasSliderSensor = Sensor.isSupported (Sensor.SLIDE);
    statusField1.setText ("Flip:" + hasFlipSensor + "\nHolster:")
    + hasHolsterSensor + "\nSlider:" + hasSliderSensor + "\n"); "."
    Check the status of a sensor
    If (Sensor.isSupported (Sensor.SLIDE))
    {
    int sliderState = Sensor.getState (Sensor.SLIDE);
    Switch (sliderState)
    {
    case Sensor.STATE_SLIDE_CLOSED:
    do something if the cursor is closed
    statusField2.setText ("cursor is closed.");
    break;
    case Sensor.STATE_SLIDE_IN_TRANSITION:
    do something about cursor in transition
    statusField2.setText ("Slider is between open and closed.");
    break;
    case Sensor.STATE_SLIDE_OPEN:
    do something if the cursor is open
    statusField2.setText ("slider is open.");
    break;
    by default:
    statusField2.setText ("cannot determine the State of the cursor from.");
    }
    }
    Listening to changes to a sensor
    Sensor.addListener (Application.getApplication (),)
    Sensor.SLIDE);
    }

    implementation of the SensorListener.onSensorUpdate)
    change cursor only checks
    ' public void onSensorUpdate (int sensorID, int update)
    {
    If (sensorID is Sensor.SLIDE)
    {
    If (update is Sensor.STATE_SLIDE_OPEN)
    {
    do something if the cursor is now open
    statusField2.setText ("Slider is now open.");
    }
    ElseIf (update == Sensor.STATE_SLIDE_IN_TRANSITION)
    {
    do something if the cursor is now transitioning
    statusField2.setText ("Slider condition changes.");
    }
    ElseIf (update == Sensor.STATE_SLIDE_CLOSED)
    {
    do something if the cursor is now closed
    statusField2.setText ("Slider is now closed.");
    }
    }
    }
    }
    }

    .................

    Manoj Kumar bakkar

  • Update of the main screen to a background thread

    Hi guys im trying to update the main screen from a background thread. in this case I'm using a 2 static pictures. Once I click on a butotn on the popupScreen when the application is loaded, it will update the image on the main screen.

    I wrote a small excerpt for it and can you please give me some help with this. because when I've debugged and one of the developers helped me thereby to discover that the screen im trying to update is not the active screen.  Please have alook please.ive extract have 3 classes here

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    SerializableAttribute public class MyApp extends UiApplication
    {

    Public Shared Sub main (String [] args)
    {
    Create a new instance of the application and make the currently
    who runs the thread of the application of the event dispatch thread.
    MyApp PAP = new MyApp();
    theApp.enterEventDispatcher ();
    }
        
    /**
    * Creates a new object MyApp
    */
    public MyApp()
    {
    Push a screen onto the stack in the user interface for rendering.
    pushScreen (new MyScreen());
    final Pinpopup pp = new Pinpopup();

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    UiApplication.getUiApplication () .pushModalScreen (pp);
    }
    });
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////

    / public final class screen extends MyScreen
    {
    /**
    * Creates a new object of MyScreen
    */
    public Bitmap bmp image;
    public BitmapField bmpField;
    public ButtonField btnDisplay;
    public ImageThread imgThread;
            
    public MyScreen()
    {
            
    Set the displayed title of the screen
    setTitle ("MyTitle");
    BMP = Bitmap.getBitmapResource ("image.png");
    btnDisplay = new ButtonField ("Display");
    bmpField = new BitmapField (bmp);

    btnDisplay.setChangeListener (new FieldChangeListener() {}
                
    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
                    
    if(Field == btnDisplay)
    {
    BMP = Bitmap.getBitmapResource ("image1.png");
    bmpField.setBitmap (bmp);
    signInButtonClicked ("07760926037", "1234");
    LaunchImageThread();
                        
    }
    }
    });
            
    Add (bmpField);
    Add (btnDisplay);
            
    }
        
        
    Public Sub LaunchImageThread()
    {
    imgThread = new ImageThread (this);
    System.out.println ("THIS screen:" + this.getScreen ()); I realized that the im screen update is not active but its strange I don't create any other refrence so
    New Thread (imgThread) m:System.NET.HttpListener.start ();
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// POPUPSCREEN CLASS
    class Pinpopup extends PopupScreen //implements FieldChangeListener
    {
    private ButtonField btnOk;
        
    Pinpopup()
    {
            
    Super (new HorizontalFieldManager());

    btnOk = new ButtonField ("Sign In");

    btnOk.setChangeListener (new FieldChangeListener() {}

    ' Public Sub fieldChanged (field field, int context)
    {
    TODO self-generating method stub
    Try
    {
    if(Field == btnOK)
    {
    Close();
    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();
    }
    } catch (IllegalArgumentException e) {}
    TODO: handle exception
    System.out.println ("Exception Popup all in signingIn" + e.getMessage ());
    }
    }
    });
            
    Manager fieldManagerContext = new Manager (USE_ALL_WIDTH)
    {
    ' public void sublayout (int width, int height) {}

    int xPos = 10;
    int ypos = 40;

    Field = getField (0);
    layoutChild (field, 280, 50);
    setPositionChild (field, xpos ypos + 100 + 165);

    setPosition (300, 300);
    setExtent (350, 225);
    }
    };
            
    fieldManagerContext.add (btnOk);
    Add (fieldManagerContext);
    }
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////

    / public class ImageThread implements Runnable
    {
    private MyScreen parent;
        
    public ImageThread (MyScreen myScreen)
    {
    parent = myScreen;
    }

    public void run()
    {
    Try
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
                    
    public void run() {}
    TODO self-generating method stub
    System.out.println ("active screen:" + UiApplication.getUiApplication () .getActiveScreen ());
    System.out.println ("active screen:" + parent.getScreen ());
    parent.bmp = Bitmap.getBitmapResource ("image1.png");
    parent.bmpField.setBitmap (parent.bmp);
                        
    }
    });
    }
    catch (Exception ex)
    {
    System.out.println ("Exception in Thread:" + ex.getMessage ());
    }
    }
    }

    was soon thanks

    I suspect that this is your problem:

    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();

    I suspect that if you did as I suggested on the other Thread and put a breakpoint in the constructor of MyScreen, you'd have foiund, this creates a second instance.

    I hope that you can take it from here.

  • Urbanship autostartup main method does not

    Hi friends,

    I use urbanship push notification they gave the following code to the main method.

    To autostartup.

    I use jde 6.0

    I followed the step project > properties > Application tab > checked Autostart (box) and module system.

    but my (if) statements of autostartup does not.

    Public Shared Sub main (String [] args) {}
    UrbanAirshipMain nd = new UrbanAirshipMain();

    If (args.length > 0 & args [0] .equals ('autostartup'))

    {

    Application push registry

    nd.registerPushApplication ();

    Create a background process on restarting the device, not user interface

    nd.enterEventDispatcher ();

    }

    on the other

    {

    DISP lay User Interface starts in the foreground

    nd.showGUI ();

    }

    }

    can someone help me. Thanks in advance...

    Kind regards

    Sirot

    You actually spend "autostartup' as a parameter?

    Try a trace here to know what really comes as an argument.

  • Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver


    Dear Sir


    I have this problem to connect the JAVA oracle database. I use Eclipse March, here is my code:

    package db;

    import java.sql.Connection;

    to import java.sql.DriverManager;

    import java.sql.SQLException;

    public class {ConnectionFactory

    public static {connection getConnection()

    try {}

    Class.forName ("oracle.jdbc.OracleDriver");

    return DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "Tiger");

    } catch (ClassNotFoundException |) SQLException e) {}

    throw new RuntimeException (e);

    }

    }

    Public Shared Sub main (String [] args) {}

    Connection connection = ConnectionFactory.getConnection ();

    System.out.println ("Conexao criada com sucesso.");

    try {}

    Connection.Close;

    } catch (SQLException e) {}

    e.printStackTrace ();

    }

    }

    }

    Belown the error:

    Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

    DB. ConnectionFactory.getConnection (ConnectionFactory.java:14)

    DB. ConnectionFactory.main (ConnectionFactory.java:19)

    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

    at java.net.URLClassLoader.findClass (unknown Source)

    at java.lang.ClassLoader.loadClass (unknown Source)

    to Sun.misc.Launcher$appclassloader$ AppClassLoader.loadClass (unknown Source)

    at java.lang.ClassLoader.loadClass (unknown Source)

    at java.lang.Class.forName0 (Native Method)

    at java.lang.Class.forName (unknown Source)

    DB. ConnectionFactory.getConnection (ConnectionFactory.java:11)

    ... 1 more

    Someone help me, please?

    Thank you

    Jurandyr F. Alves

    A ClassNotFound exception means just what it says: it can't find this class.

    Make sure that the ojdbc7.jar file is in your classpath.

  • Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

    Hi all

    the test of the first example using the chap Jena adapter query 7 in the developer's guide, I got the error "Exception in thread"main"java.lang.ArrayIndexOutOfBoundsException: 0".» I don't see the bugs in this example. Can someone give me pls advice? Thanks in advance. the code is as follows:

    Oracle.spatial.rdf.client.jena import. *;
    import com.hp.hpl.jena.rdf.model.Model;
    com.hp.hpl.jena.graph import. *;
    com.hp.hpl.jena.query import. *;
    public class Test {}
    Public Shared Sub main (String [] args) throws exceptions
    {

    String szJdbcURL = args [0];
    String szUser = args [1];
    String szPasswd = args [2];
    String szModelName = args [3];

    Oracle Oracle = new Oracle (szJdbcURL, szUser, szPasswd);
    Model = ModelOracleSem.createOracleSemModel)
    Oracle, szModelName);
    model.getGraph () .add (Triple.create)
    Node.createURI ("http://example.com/John"),
    Node.createURI ("http://example.com/fatherOf"),
    "Node.createURI ("http://example.com/Mary")));"
    Query query = QueryFactory.create)
    "Select? f? k WHERE {? f < http://example.com/fatherOf >? k.} ») ;
    QueryExecution qexec = QueryExecutionFactory.create (query, model);
    ResultSet results = qexec.execSelect ();
    ResultSetFormatter.out (System.out, results, query);
    Model.Close ();
    Oracle.Dispose ();
    }
    }

    The program requires a certain arguments. Do you provide these arguments?

    Thank you

    Zhe

  • How can I do to block the main thread when to display a dialog box

    I have a problem to block the user interface main thread when to display a dialog box (the dialog was created by the main Application), and when the dialog box is closed, the main Application can go to the next step.
    Here is my code:

    SerializableAttribute public class TitledPaneExample extends Application {}
    instance of TitledPaneExample private;
    StackPane mainModalDimmer;

    /*
    * (non-Javadoc)
    *
    * @see javafx.application.Application #start (javafx.stage.Stage)
    */
    @Override
    public void start (point primaryStage) bird Exception {}
    instance = this;
    primaryStage.setTitle (this.getClass () m:System.NET.SocketAddress.ToString ());

    final StackPane layerPane = new StackPane();
    layerPane.setDepthTest (DepthTest.DISABLE);
    layerPane.setStyle ("background - fx - color: BLACK ;"); ")

    Vb VBox = new VBox();
    vb.setStyle ("background - fx - color: BLUE ;"); ")
    vb.getChildren () .add new (Label ("1"));
    vb.getChildren () .add (Label ("2")) new;
    vb.getChildren () .add new (Label ("3"));
    vb.getChildren () .add (Label ("4")) new;

    Bt1 button = new Button ("bt1");
    BT1.setOnAction (new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent event)
    System.out.println ("bt1 trying to the new dialog box > > >");
    Dialogue di = new dialog box (instance, "some trick here!");
    System.out.println ("bt1 dialogue again successfully, try to show");
    di. Show();
    System.out.println ("bt1 dialog hide? < < < < ");"
    }
    });
    vb.getChildren () .add (bt1).

    layerPane.getChildren () .add (vb);

    mainModalDimmer = new StackPane();
    mainModalDimmer.setId ("MainModalDimmer");
    mainModalDimmer.setMaxSize (Double.MAX_VALUE, Double.MAX_VALUE);
    mainModalDimmer.setVisible (false);
    mainModalDimmer.setStyle ("background - fx - color: RED ;"); ")
    layerPane.getChildren () .add (mainModalDimmer);

    Scene sc = new scene (layerPane, 800, 600);
    primaryStage.setResizable (true);
    primaryStage.setScene (sc);
    primaryStage.show ();

    }

    /**
    * Display the node given as a floating dialog on the entire application, with
    * the rest of the application grayed out and blocked from mouse events.
    *
    @param message
    */
    {} public void showModalMessage (message from node)
    mainModalDimmer.getChildren () .add (message);
    mainModalDimmer.setOpacity (0);
    mainModalDimmer.setVisible (true);
    mainModalDimmer.setCache (true);
    TimelineBuilder
    . Create()
    () .keyFrames
    new KeyFrame (Duration.seconds (1),)
    new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent t)
    mainModalDimmer.setCache (false);
    }
    }, new KeyValue (mainModalDimmer
    . opacityProperty(), 1.
    Interpolator.EASE_BOTH))) infrastructure)
    . Play();
    }

    /**
    Hide the any modal message that appears
    */
    public void hideModalMessage() {}
    mainModalDimmer.setCache (true);
    TimelineBuilder
    . Create()
    () .keyFrames
    new KeyFrame (Duration.seconds (1),)
    new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent t)
    mainModalDimmer.setCache (false);
    mainModalDimmer.setVisible (false);
    mainModalDimmer.getChildren () .clear ();
    }
    }, new KeyValue (mainModalDimmer
    . opacityProperty(), 0,.
    Interpolator.EASE_BOTH))) infrastructure)
    . Play();
    }

    /**
    @param args
    */
    Public Shared Sub main (String [] args) {}
    Launch();
    }

    Dialogue/public class extends TitledPane {}
    private owner of TitledPaneExample = null;
    instance of TitledPane private;

    Dialogue (owner of TitledPaneExample, String message) {}
    This.Owner = owner;
    this.parentThreand = Thread.currentThread ();
    This.instance = this;
    this.setExpanded (true);
    this.setText ("Dialog");
    this.setMaxWidth (400);
    this.setPrefWidth (300);
    this.setMinWidth (200);

    Label the tx = new Label ("message");
    tx.setTooltip (new Tooltip (message));
    tx.setWrapText (true);
    tx.setContentDisplay (ContentDisplay.LEFT);

    Bt button = new Button ("OK");
    bt.setOnAction (new EventHandler < ActionEvent > () {}
    {} public void handle (ActionEvent event)
    masquer();
    }
    });

    Sp ScrollPane = new ScrollPane();
    sp.setHbarPolicy (ScrollBarPolicy.AS_NEEDED);
    sp.setVbarPolicy (ScrollBarPolicy.AS_NEEDED);
    sp.setContent (tx);

    Hb HBox = new HBox (30);
    hb.setPrefHeight (40);
    hb.setAlignment (Pos.CENTER_RIGHT);
    hb.getChildren () .add (bt);

    BP BorderPane = new BorderPane();
    bp.setCenter (sp);
    bp.setBottom (hb);

    this.setContent (bp);
    }

    {} public void show()
    System.out.println ("dialogue show() 1 > > >");

    owner.showModalMessage (instance);

    System.out.println ("dialogue show() 2 > > >");

    }

    public void masquer() {}
    System.out.println ("dialogue masquer() 1 > > >");
    this.owner.hideModalMessage ();

    System.out.println ("dialogue masquer() 2 > > >");
    }
    }

    }

    I'm also interested in how to do this without the use of a step.

    But, if you are ready to use a step for this, you can create a useful first step (without borders) with its owner being your current stage. Then, you can call the function showAndWait on stage that allows to block the thread of your application. For example, I implemented a DialogStage like this:

    package hs.mediasystem.util;
    
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.Timeline;
    import javafx.event.EventHandler;
    import javafx.scene.effect.ColorAdjust;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    import javafx.stage.WindowEvent;
    import javafx.util.Duration;
    
    public class DialogStage extends Stage implements Dialog {
    
      public DialogStage() {
        super(StageStyle.TRANSPARENT);
    
        this.setTitle("MediaSystem-dialog");
    
        initModality(Modality.APPLICATION_MODAL);
      }
    
      protected void setParentEffect(Stage parent) {
        ColorAdjust colorAdjust = new ColorAdjust();
    
        Timeline fadeOut = new Timeline(
          new KeyFrame(Duration.ZERO,
            new KeyValue(colorAdjust.brightnessProperty(), 0)
          ),
          new KeyFrame(Duration.seconds(1),
            new KeyValue(colorAdjust.brightnessProperty(), -0.5)
          )
        );
    
        parent.getScene().getRoot().setEffect(colorAdjust);
    
        fadeOut.play();
      }
    
      protected void removeParentEffect(Stage parent) {
        parent.getScene().getRoot().setEffect(null);
      }
    
      protected void recenter() {
        Window parent = getOwner();
    
        sizeToScene();
    
        setX(parent.getX() + parent.getWidth() / 2 - DialogStage.this.getWidth() / 2);
        setY(parent.getY() + parent.getHeight() / 2 - DialogStage.this.getHeight() / 2);
      }
    
      @Override
      public final void showDialog(final Stage parent, boolean synchronous) {
        initOwner(parent);
    
        setParentEffect(parent);
    
        setOnShown(new EventHandler() {
          @Override
          public void handle(WindowEvent event) {
            recenter();
            onShow();
          }
        });
    
        if(synchronous) {
          showAndWait();
        }
        else {
          show();
        }
      }
    
      protected void onShow() {
      }
    
      @Override
      public void close() {
        removeParentEffect((Stage)getOwner());
        super.close();
      }
    }
    
  • Exception in thread "main" java.lang.NoClassDefFoundError: hand

    Hello!


    To run my java application, I try to run the cmd of the following command:
    ... \bin > java hand

    and I get the following exception:

    Exception in thread "main" java.lang.NoClassDefFoundError: hand
    Caused by: java.lang.ClassNotFoundException: hand
    in java.net.URLClassLoader$ 1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged (Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    to Sun.misc.Launcher$appclassloader$ AppClassLoader.loadClass (Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    The main class is not found: hand. Program ends.



    1. principal is Main.class I try to run where there is
    Public Shared Sub main (String [] args) {}
    Test test = new Test ("Test");
    test.setVisible (true);
    }

    2. in 'Path', I have "C:\Program Files\Java\jdk1.6.0_26\bin"
    3. in the 'src' folder I also Test.java file Main.java in addition
    4. in the folder "bin" are the files Test.calss and Main.class
    5. in eclipse, it works correctly

    What can be the problem?
    Thank you!

    800512 wrote:
    What can be the problem?

    Not sure how the classpath. Which is nothing to be ashamed that you started with Eclipse, it is exactly one of those things that an IDE hides on your part.

    Read into java classpath and things will be clear. For now, you'll get it to work by running this:

    Java - cp. Main

    (Note the point - which means "current working directory" as part of a path).

  • Complie error "Exception in thread"main"java.lang.NoClassDefFoundError".

    Dear all,

    I have the following problem can not compile the code below.
    My settings and the code here.

    Thanks for the help.

    My version of java.
    ===============================================
    D:\bea\jdk150_22\bin > java-version
    Java version "1.5.0_22.
    Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22 - b03)
    Java Client VM (build 1.5.0_22 - b03, mixed mode)
    ===============================================

    I use a bat to compile the code
    ===============================================
    Set of JDK_HOME = D:\bea\jdk150_22
    set PATH=%JDK_HOME%\bin;%PATH%
    Set CLASSPATH=%CLASSPATH%;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar

    REM - compile
    javac GetDBOracle.java

    REM - tests
    Java GetDBOracle

    REM - add to jar
    jar cf GetDBOracle.jar GetDBOracle.class
    ===============================================

    My java code

    ===============================================
    import java.sql. *;
    import java. IO;

    public class GetDBOracle {}
    public static String GetDBOracle (String Parm1, Parm2 String) throws SQLException
    {
    Same string = "";
    Load the Oracle driver
    DriverManager.registerDriver (oracle.jdbc.OracleDriver (()) new;
    Connect to the local database
    Connection Conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@localhost:ORCL", "ORC", "ORC2010");
    Ask the names of the employees
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("SELECT JAVA_GET_VALUE('"Parm1"','"Parm2"') FROM DUAL");
    Print name
    While (rset.next ()) {}
    Ditto = rset.getString (1);
    }
    close the result set, statement and connection
    RSet.Close ();
    stmt. Close();
    Conn.Close ();
    return same;
    }
    Public Shared Sub main (string args [])
    {
    try {}
    System.out.println (GetDBOracle ("XXI", "12000"));
    } catch (Exception e) {}
    System.out.println (e.getMessage ());
    }
    }
    }
    ===============================================

    ERRO
    ===============================================
    Exception in thread "main" java.lang.NoClassDefFoundError: GetDBOracle
    ===============================================

    Kayaman was referring to the complexity of classpath and how experts mess it upward, nothing to do with the forum sites.

  • Exception in thread "main" java.lang.NoClassDefFoundError: oracle/aurora/is

    Hi, I created 1 java class that we use to run unix from a plsql package commands.

    1 class file is

    package xxxxx.oracle.apps.custom;
    import java. IO;

    public class OsCommand {}
    Public Shared Function execute (String command) {}
    String result = "";
    String error = "";

    try {}
    InputStream stdin = null;
    int exitVal = 0;
    String line = null;
    String return_line = null;

    Execution run_time = Runtime.getRuntime ();
    Treat the ch = run_time.exec (command);

    InputStreamReader isr = new InputStreamReader (ps.getInputStream ());
    BufferedReader br = new BufferedReader (isr);

    InputStreamReader errorStreamReader = new InputStreamReader (ps.getErrorStream ());
    BufferedReader bufferedError = new BufferedReader (errorStreamReader);

    While ((line = bufferedError.readLine ())! = null)
    error = line;

    While ((line = br.readLine ())! = null)
    result = line;
    return (error == ""?) result: "invalid:" + error);
    }
    catch (Exception ex) {return "invalid:"+ ex.toString () ;} "}
    }

    Public Shared Sub main (String [] args) {}
    System.out.println (Execute(args[0]));
    //}
    }

    2 we have a shell script to compile this class file that works as well, which (Oscommand.sh) contains

    $AF_JRE_TOP/bin/javac - classpath /u04/appldev/11i/apps/xxxxcustom/11.5.0/ar/java-proc OsCommand.java.

    3 to load this class file, we have another shell script that throws an exception is

    # script to load the java class in the shell database
    APPS_PWD = xxxxxxxx

    # The directory containing the class file to be loaded into the database
    FULL_PATH=/U04/appldev/11i/apps/xxxxxcustom/11.5.0/ar/Java-proc

    # The name of the class file
    JAVA_CLASS_FILE = OsCommand.Class

    /U01/app/Oracle/product/10.2/bin/loadjava u apps / ${APPS_PWD} - v.
    -solve - resolver ' ((* SCOTT) (* PUBLIC) (* ADMIN))'.
    ${FULL_PATH} / ${JAVA_CLASS_FILE}

    When I run the 3rd script I get the follwing exception message

    "Exception in thread"main"java.lang.NoClassDefFoundError: oracle/aurora/Server/tools/loadjava/LoadJavaMain.


    Could someone please help what could be wrong with the code.


    Thank you
    Malla

    Published by: user4254752 on July 14, 2009 13:22

    Malla,

    See the following documents.

    Note: 114009.1 - storage and loading of the Java Classes in the database
    Note: 131812.1 - how to run example Java stored procedure Hello.java

    Kind regards
    Hussein

  • TestStand Java - 1500 error cannot find the class

    Hello world

    I use Java 1.7 and TestStand 2010.

    I try to add a java class in the computer example folder and call the method.

    The java class is just as below, because I'm just trying to call my own java class.

    I put the class path to start the JAVA virtual machine in the directory where the example of the computer (which is also the directory where I put my java class).

    TestStand can call methods of the computer, but not mine (received the error 1500 error cannot find class). I put my my java method call among calls for default computer example.

    Also I read similar topics, but again I can not resolve the error.

    Where is the part that I'm bored, in fact? Please share some ideas.

    Note: I even try to leave the empty class path, but TestStand can always call the methods of the computer. Why?

    ----------------------

    public class TestJava {}

    Public Shared Sub main (String [] args) {}

    }

    public String returnString(boolean a) {}
    Return "success";
    }

    }

    To load a class which is within a package, you can use the package rating (or change the example in order to to use). The path to the class is passed directly to the JAVA virtual machine to load the class, but really what is necessary is the package from the class path, including the full path to the class.

    This means you need to do the following:

    1 set the class path in the base directory where you created all your classes, if you have the following structure:

    • MyFile.java
    • builds
      • MyPackage
        • MyFile.class

    You must set the classpath in the builds directory

    2 when you set up your steps, you must set the path to the class in your steps from Java to MyPackage/MyFile.class (note the separator is a forward slash, not used Windows backslash, then the Browse button is not quite help with that).

    Another important thing is that when you set the classpath variable you remove the normal Java class path, if you are using Java classes from the library by default, you may have to add \lib\rt.jar

  • Problems with video recording

    Hello

    I have some problems with the video recording on the BlackBerry.

    On the BB 9700 my application crashes when I try to stop recording. The file produced
    the app is empty.
    On BB 9800 I have the same problem unless I have explicitly defined the video resolution, but
    in this case, the resolution of the resulting video is different from what I
    specify (640 x 480 instead of 320 x 240).
    On BB 9300 an application works without problem.

    Here's the example I use:

    //////////////////////////////////////// App.java
    VCR package;

    Import net.rim.device.api.ui.UiApplication;

    public class App extends UiApplication
    {

    Public Shared Sub main (String [] args)
    {
    final App app = new App();
    app.enterEventDispatcher ();
    }

    public App()
    {
    last screen VideoRecorderScreen = new VideoRecorderScreen();
    pushScreen (screen);
    }

    }

    VideoRecorderScreen.java
    VCR package;

    import java.io.IOException;
    import java.util.Timer.
    java.util.TimerTask to import;

    Import javax.microedition.media.MediaException;

    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.container.MainScreen;

    / public final class VideoRecorderScreen extends screen
    {

    Private final int DELAY = 1000;

    Private final String VIDEO_PATH = "file:///SDCard/BlackBerry/videos/video.3gp";
    Private final String VIDEO_ENCODING = "video/3gpp";
    Private final int VIDEO_DURATION = 5000;
    Private final int VIDEO_WIDTH = 320;
    Private final int VIDEO_HEIGHT = 240;

    recorder recorder private;

    Public Sub onDisplay()
    {
    new timer() .schedule (new TimerTask() {}
    public void run() {}
    Start();
    }
    (}, DELAY);
    }

    private void start()
    {
    Exception Exception = null;
    try {}
    This.Recorder = new recorder (this. VIDEO_ENCODING, this. VIDEO_WIDTH, this. VIDEO_HEIGHT);
    This.Recorder.record (this.) VIDEO_PATH);
    } catch (MediaException ex) {}
    Exception = ex;
    } catch (IOException ex) {}
    Exception = ex;
    }

    If (exception! = null) {}
    Warn (exception);
    return;
    }

    new timer() .schedule (new TimerTask() {}
    public void run() {}
    try {}
    VideoRecorderScreen.this.recorder.end ();
    warn ("check");
    } catch (IOException ex) {}
    Warn (ex);
    }
    }
    }, this. VIDEO_DURATION);
    }

    private void warn (Object, object)
    {
    the final String message = String.valueOf (object);
    UiApplication.getApplication () .invokeLater (new Runnable() {}
    public void run() {}
    Dialog.Alert (message);
    }
    });
    }

    }

    Recorder.Java
    VCR package;

    import java.io.IOException;

    Import javax.microedition.media.Manager;
    Import javax.microedition.media.MediaException;
    Import javax.microedition.media.Player;
    Import javax.microedition.media.control.RecordControl;

    public class logger
    {

    Final private player vp;

    private RecordControl rc;

    Recorder of public (encoding String, int w, int h)
    throws MediaException, IOException
    {
    This.VP = Manager.createPlayer ("capture://video?encoding=" + coding
    + '&' + 'Width' + '=' + w
    + '&' + 'height' + '=' + h);
    }

    public void save (String path)
    throws MediaException, IOException
    {
    This.VP.Start ();

    This.RC = this.vp.getControl ("RecordControl") (RecordControl);
    If (this.rc == null) {}
    throw new MediaException ("RecordControl could not be obtained");
    }

    this.rc.setRecordLocation (path);
    this.rc.startRecord ();
    }

    public void end()
    throws IOException
    {
    If (this.rc == null) {}
    throw new IllegalStateException ("RecordControl not initialized");
    }

    this.rc.stopRecord ();
    This.rc.Commit ();

    //
    This.VP.Close ();
    }

    }

    Upgrade to an operating system that has the fix is the only solution I'm aware of, but depending on who may or may not be an option.

  • A screen popup menu is opened after the closure of the dialog box

    Hello

    I have a test application with a screen containing a button.

    When I click on the button (pressing the button on my BlackBerry 9220 trackpad), it opens a dialog box.

    Then when I press ESC to my BlackBerry 9220, it closes the dialog box and I'm back on my screen.

    Now, if I add to my screen, a menu item, the changes in behavior:

    When I click on the button (pressing the button on my BlackBerry 9220 trackpad), it opens a dialog box.

    Then when I press ESC to my BlackBerry 9220, it closes the dialog box and opens a menu screen.

    So, I would add my item of menu but keeping the old behavior of my application after you close the dialog box.

    Any idea?

    Thank you.

    Best regards.

    Here is the code:

    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.FieldChangeListener;
    Import net.rim.device.api.ui.MenuItem;
    Import net.rim.device.api.util.StringProvider;
    SerializableAttribute public class TestApplication extends UiApplication
    {
    public TestApplication()
    {
    this.pushScreen (new TestScreen());
    }
    Public Shared Sub main (String [] args)
    {
    Application TestApplication = new TestApplication();
    application.enterEventDispatcher ();
    }
    }
    final TestScreen class extends FieldChangeListener implements screen
    {
    public TestScreen()
    {
    / * MyMenuItem MenuItem = new MenuItem (new StringProvider ("my menu item"), 0 x 230000, 0); * /
    ButtonField myButtonField = new ButtonField ("button my field");
    myButtonField.setChangeListener (this);
    This.Add (myButtonField);
    / * this.addMenuItem (myMenuItem); * /
    }
    ' Public Sub fieldChanged (field field, int context)
    {
    Dialog.Alert ("test");
    }
    }

    Here are a few screenshots:

    It comes from the popup menu. create the button with CONSUME_CLICK would be the simplest solution.

  • Listener Button problem

    This is my first attempt at development for the BB storm, and I use JDE 4.7.

    I started with a Hello World application, I found and I modified to add a simple button that says RED. When you click on I tried the wallpaper turn RED and change the button to say BLUE, when that is clicked on it turns BLUE changes back to RED button again.

    I've implemented this, use a standard listener ButtonField (which I call bhandler in my code). The program type of works, with the odd effect only on the Simulator is that when I click the button, the background color changes but a little menu appears. Anyone else seen this problem of menu? I don't expect to see a menu and I have not coded anything to ask for a menu appear when I click on this button.

    Here is my source code. The Manager is in bold. All the answers that I see not why only a menu would be most appreciated... Thank you.

    /**
    * HelloWorld.java
    * Copyright (C) 2001-2003 research In Motion Limited. All rights reserved.
    */
    package com.rim.samples.helloworld;

    Net.rim.device.api.ui import. *;
    Net.rim.device.api.ui.component import. *;
    Net.rim.device.api.ui.container import. *;
    Net.rim.device.api.system import. *;
    Net.rim.device.api.ui.decor import. *;

    /*
    * BlackBerry applications that provide a user interface
    * must extend UiApplication.
    */
    SerializableAttribute public class HelloWorld extends UiApplication
    {
    Public Shared Sub main (String [] args)
    {
    create a new instance of the application
    and launch the application on the event thread
    HelloWorld APP = new HelloWorld();
    theApp.enterEventDispatcher ();
    }
    public HelloWorld()
    {
    a new screen
    pushScreen (new HelloWorldScreen());
    }
    }

    create a new screen that covers the screen, which provides
    standard behavior by default for BlackBerry applications
    final HelloWorldScreen class extends screen
    {
    public HelloWorldScreen()
    {

    call the constructor of the screen
    Super();

    Add a title to the screen
    LabelField title = new LabelField ("HelloWorld example", LabelField.ELLIPSIS
    | LabelField.USE_ALL_WIDTH);
    setTitle (title);

    Add the text "Hello World!" to the screen
    Add (new RichTextField ("Hello World!"));
                    
    First define the button handler
                    FieldChangeListener bhandler = new FieldChangeListener()
    {
    ' Public Sub fieldChanged (field field, int context)
    {
    ButtonField buttonField = field (ButtonField);
    If (buttonField.getLabel () is 'RED')
    {
    Bottom newback = BackgroundFactory.createSolidBackground (Color.RED);
    getMainManager () .setBackground (newback);
    buttonField.setLabel ("BLUE");
    }
    on the other
    {
    Bottom newback = BackgroundFactory.createSolidBackground (Color.BLUE);
    getMainManager () .setBackground (newback);
    buttonField.setLabel ("RED");
    }
    }
    };

    Define the button itself use Manager above, this one called RED
    ButtonField buttonField = new ButtonField ("RED");     Create a RED button
    buttonField.setChangeListener (bhandler);               Implement the handler for button defined above
                     
    Add (buttonField);  Adds the button to the screen.

    }

    Override the onClose() method to display a dialog to the user
    with "Goodbye!" when the application is closed
    public boolean onClose()
    {
    Dialog.Alert ("Goodbye!");
    System.Exit (0);
    Returns true;
    }
    }

    Solved in Java development.

  • Refresh the field label

    Hi, I read many posts on the forum but I have not found any that solved my problem.

    I'm new to the development of BB and I'm having a problem that I seem not to be able to untangle.

    I have a main class and a class of the screen. I have a button that launches a datepicker. When the DatePicker is closed I need the label of the button to refresh with the selected value. How should I do?

    I tried with invalidate, creating a CustomButtonField that implements different onFocus, onUnFocus and some other stuff, but I guess I have them implemented in a bad way...

    My two classes are these...

    public class TestClass extends UiApplication
    {

    public static calendar alarm1time = Calendar.getInstance (TimeZone.getTimeZone("GMT-3"));

    Public Shared Sub main (String [] args)
    {

    TestClass testClass = new TestClass ();
    testClass.enterEventDispatcher ();

    }

    Public TestClass()
    {

    pushScreen (new TestClassScreen());

    }

    }

    / public final class TestClassScreen extends screen
    {

    public TestClassScreen()
    {

    ButtonField alarm1 = new ButtonField ("alarm:" + TestClass.alarm1time.get (Calendar.HOUR_OF_DAY) + ":" + TestClass.alarm1time.get (Calendar.MINUTE), ButtonField.FOCUSABLE)

    {

    public boolean navigationClick (int status, int time)
    {

    datePicker (1);
    Returns true;

    }

    };

    setTitle ("Test alarm");
    Add (new RichTextField(""));
    Add (alarm1);

    }

    public void datePicker (mutable int alarmNumber)
    {

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {

    public void run()
    {

    DateTimePicker datePicker = null;
    datePicker = DateTimePicker.createInstance (TestClass.alarm1time, null, "HH: mm");
    If (datePicker.doModal ())
    {

    Calendar cal = datePicker.getDateTime ();
    TestClass.alarm1time = cal.

    Here I need the label to be updated, in the end the datePicker is Ok

    }

    }

    });

    }

    }

    Thank you

    Alex

    Welcome to the forums.

    Here's one way:

    public boolean navigationClick (int status, int time)
    {

    datePicker(1, this);
    Returns true;

    }

    Public Sub switch of dates (alarmNumber final int, ButtonField buttonToUpdate final)
    {

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {

    public void run()
    {

    DateTimePicker datePicker = null;
    datePicker = DateTimePicker.createInstance (TestClass.alarm1time, null, "HH: mm");
    If (datePicker.doModal ())
    {

    Calendar cal = datePicker.getDateTime ();
    TestClass.alarm1time = cal.

    buttonToUpdate.setLabel (...)}

    }

    });

    }

    A more usual way of being having change listener listen to click on the button and perform a similar treatment in there.

    Edit: The Code has been corrected.

Maybe you are looking for