Problem in run the Java ME application using jar file

Hi all,
I am using Eclipse 3.3 with CLDC and MIDP, I add external jar file for my application. The jar contains MIDlet and some classes. I create a class (not MIDlet) that have same package name and Class as in jar file.
Say for example the jar file have com.Displaytext and My new project have com.Displaytext.
The problem is my application takes the class file in external jar but my intent is the application class file needs to work.
I welcome your answers.
Edited by: chals on Aug 23, 2008 12:24 PM
Edited by: chals on Aug 23, 2008 12:25 PM
Edited by: chals on Aug 23, 2008 12:37 PM

For class loading inside or outside of JAR files I use this code:
void loadClass (String className) {
    String prefix = "de.test.";
    String postfix = ""; // use this if your classes have a name pattern
    Object o = Class.forName(prefix + className + postfix).newInstance();
void loadClass (String className, Class[] paramClasses, Object[] params) {
    String prefix = "de.test.";
    String postfix = ""; // use this if your classes have a name pattern
    Object o = Class.forName(prefix + className + postfix).getConstructor(paramsClasses).newInstance(params);
}

Similar Messages

  • Strange problem with my ClassFactory when a non used jar file is missing.

    Hello,
    I have a small problem regarding a class factory and I don't really understand how to solve it.
    If you see the example below we can imagine that I have a classFactory who can provide 3 different types of classes.
    public class ClassFactory {
    public ClassFactory() {
    public static Service getClass(String szType) {
    if(szType.equals("1")) {
    return new Class1();
    } else if (szType.equals("2")) {
    return new Class2();
    } else if (szType.equals("3")) {
    return new Class3();
    else {
    return null;
    My problem is the following. Let�s imagine that Class1 and Class2 do not use specific jar file but Class3 uses a jar file which is not always present in old installation.
    I thought that it was possible to get this factory running correctly if the customer only uses Class1 and Class2 same if specific jar file used by Class3 was not present but this is not the case.
    I remarked that if the specific jar file used in Class3 was not present in my classpath the ClassFactory is blocking (same if we do not try to get a "Class3").
    My problem is that I want to keep my code backward compatible without asking the customer to add a new jar file only used in new installation.
    Can anyone of you explain me why it is reacting like this and how can I solve this problem?
    Thank in advance for your reply.
    Alain.

    There's a standard way of handling these things now. You place a text file in each jar that contributes candidate concrete classes with the FQN of an implementing class on each line. Your factory class then collects all these using getResources() on the context class loader and loads the classes dynamically.
    The text file goes in the diretory META-INF/services and the file name is the FQN of the interface or abstract class they all implement.
    Typically there's a small factory class for each implementation and you ask each, in turn, whether they accept the specifications the caller requested of your factory (typically static getInstance() method).
    Or you could, for example, put the selection name/index or whatever in each class as an annotation.

  • I have problem running the inverted pendulum trainer using NI ELVIS.

    i have a problem running the inverted pendulum trainer using NI ELVIS. While loading the NI ELVIS bypass VI it is unable to find the "enable communications bypass.vi". could anybody please attach the VI.
    I am using NI ELVIS 2
    Thanks

    The Enable Communications Bypass VI sounds like a VI that is only included with Traditional or legacy ELVIS designed to work with the first generation ELVIS unit, not the ELVIS II/II+ or myDAQ. It sounds like the inverted pendulum trainer you have is for use with ELVIS I. In the LabVIEW Loading dialog, do you see the full path for where it's looking for the VI? Can you provide that full path? If the inverted pendulum trainer is designed to work with the older ELVIS unit, there may be a newer version that supports ELVIS II.
    Donovan

  • Using JAR file in running application and POI !

    Hi all
    I am trying to use POI HSSF f(for the first time, So pls bear with me!)or creating excel file from my java Application. I am using the jar file :
    poi-2.0-RC2-20040102.jar. Not sure if its the correct one. So If I am wrong pls correct me.
    Now I am creating a bat file to compile my application:
    @echo off
    C:\jdk1.3.1_04\bin\javac -classpath C:\POI\poi-2.0-RC2-20040102.jar MyApp.java
    pauseIt compiles fine. Now If I try to use the jar file in run.bat for running my application, it says NoClassDef FoundError:MyApp. Here is my run.bat
    java -classpath C:\POI\poi-2.0-RC2-20040102.jar MyApp
    pauseI am not able to run my application with this run.bat file . If I change the content to:
    "java MyApp.java"
    It runs but give me error: NOClassDefFoundError:import org.apache.poi.hssf.usermodel.HSSFWorkbook
    Pls suggest me about how to use jar file in running my app and how to rresolve workbook finding problem.
    Reagrds

    Try this:
    java -classpath .;C:\POI\poi-2.0-RC2-20040102.jar MyApp
    pauseNote the "dot semi-colon" at the start of the CLASSPATH. That puts the current directory in the CLASSPATH, which is where MyApp.class lives. (No package, right?)
    See if that works better.

  • Re: Running the same (Forte) application multiple times -for different

    Hi
    We had the same problem - how to deploy a number of identical applications, using each their own db.
    (for training).
    The solution we used is to wrap the entire application into different applications by using a very small
    module called KURSUS01, KURSUS02 etc, that did nothing but call the start procedure of the main app.
    Then in the dbsession connect, we made a call appname to get the application name, and appended the
    first 8 chars to the dbname. Thus our dbnames now points to logicals name: rdbdataKURSUS01, rdbdataKURSUS02 etc.
    All this allows us to deploy the identical apps in the same env, or change one version, and run both the old
    and new program on the same pc and server at the same time (eg. KURSUS01 and KURSUS02).
    I also think this is a kludge - but it works nicely!
    Jens Chr
    KAD/Denmark
    -----Original Message-----
    From: Haben, Dirk <[email protected]>
    To: 'Soapbox Forte Users' <[email protected]>
    Date: 15. januar 1999 09:41
    Subject: Running the same (Forte) application multiple times - for different business clients.
    Hi All
    We have a number of different business clients all willing to use our
    application.
    The (forte) application is to run on our machines etc for these (business)
    clients.
    All (business) clients will have their data kept in separate Oracle DBs
    (instance).
    The problem now is that the entire (forte) application is written using
    DBSessions.
    Now, depending on what business client needs to be serviced (so to speak) we
    need to attach to the right DB - or use the "right" SO.
    The two options we can think of are:
    Option1:
    Programatic change to somehow "know" what (business) client (DB) I'm talking
    about and then use the right DB.
    Pro:
    Only one forte environment to maintain
    Can run multiple (business) clients on same PC at the same time
    Con:
    Requires many program changes
    bending O-O rules(?)
    can't dynamically name SOs so can it be done at all? (ResourceMGRs maybe?)
    Option2:
    Use separate environments! One for each business client.
    Pro:
    More defined separation of app and data,
    SLA-easy
    Con:
    Maintain "n" number of environments
    Can only run the application for one environment (business client) at a time
    on one PC - Big Negative here!
    Not knowing any feasible solution to option 1 (without much code changes and
    developer moaning) I would go for option two; as I have already worked on
    multi-environment setups on VMS back at the Hydro (hi guys).
    I would appreciate any comments from anyone who has solved this problem.
    How, Why Pro Con etc.
    TIA,
    Dirk Haben
    Perth, WA
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi
    We had the same problem - how to deploy a number of identical applications, using each their own db.
    (for training).
    The solution we used is to wrap the entire application into different applications by using a very small
    module called KURSUS01, KURSUS02 etc, that did nothing but call the start procedure of the main app.
    Then in the dbsession connect, we made a call appname to get the application name, and appended the
    first 8 chars to the dbname. Thus our dbnames now points to logicals name: rdbdataKURSUS01, rdbdataKURSUS02 etc.
    All this allows us to deploy the identical apps in the same env, or change one version, and run both the old
    and new program on the same pc and server at the same time (eg. KURSUS01 and KURSUS02).
    I also think this is a kludge - but it works nicely!
    Jens Chr
    KAD/Denmark
    -----Original Message-----
    From: Haben, Dirk <[email protected]>
    To: 'Soapbox Forte Users' <[email protected]>
    Date: 15. januar 1999 09:41
    Subject: Running the same (Forte) application multiple times - for different business clients.
    Hi All
    We have a number of different business clients all willing to use our
    application.
    The (forte) application is to run on our machines etc for these (business)
    clients.
    All (business) clients will have their data kept in separate Oracle DBs
    (instance).
    The problem now is that the entire (forte) application is written using
    DBSessions.
    Now, depending on what business client needs to be serviced (so to speak) we
    need to attach to the right DB - or use the "right" SO.
    The two options we can think of are:
    Option1:
    Programatic change to somehow "know" what (business) client (DB) I'm talking
    about and then use the right DB.
    Pro:
    Only one forte environment to maintain
    Can run multiple (business) clients on same PC at the same time
    Con:
    Requires many program changes
    bending O-O rules(?)
    can't dynamically name SOs so can it be done at all? (ResourceMGRs maybe?)
    Option2:
    Use separate environments! One for each business client.
    Pro:
    More defined separation of app and data,
    SLA-easy
    Con:
    Maintain "n" number of environments
    Can only run the application for one environment (business client) at a time
    on one PC - Big Negative here!
    Not knowing any feasible solution to option 1 (without much code changes and
    developer moaning) I would go for option two; as I have already worked on
    multi-environment setups on VMS back at the Hydro (hi guys).
    I would appreciate any comments from anyone who has solved this problem.
    How, Why Pro Con etc.
    TIA,
    Dirk Haben
    Perth, WA
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Help:How can I run the J2EE Client Application? Thanks

    Help:How can I run the J2EE Client Application that will access the remote J2EE1.4 application server which runs on another host computer?
    I have developped a stateles senterprise java bean name converter and deloyed it in the j2ee1.4 application server on the host machine A. The converterbean provides the remote home interface and remote interface. At the same time I have developped the j2ee application client named convertappclient. When I access the conveter bean at host computer A through the script 'appclient.bat' as 'appclient -client convertappclient.jar', the client can access the bean sucessfully. Now I want to access the bean through the script 'appclient.bat' at host computer B,what files should I copy from host computer A to host computer B;and what the command line should be like? Thanks!
    The following are the code of the enterprise java bean and it's home interface .
    The client code is also provided.
    The enterprise java bean:
    package converter;
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.math.*;
    public class ConverterBean implements SessionBean {
    BigDecimal yenRate = new BigDecimal("121.6000");
    BigDecimal euroRate = new BigDecimal("0.0077");
    public ConverterBean() {
    public BigDecimal dollarToYen(BigDecimal dollars) {
    BigDecimal result = dollars.multiply(yenRate);
    return result.setScale(2, BigDecimal.ROUND_UP);
    public BigDecimal yenToEuro(BigDecimal yen) {
    BigDecimal result = yen.multiply(euroRate);
    return result.setScale(2, BigDecimal.ROUND_UP);
    public void ejbCreate() {
    public void ejbRemove() {
    public void ejbActivate() {
    public void ejbPassivate() {
    public void setSessionContext(SessionContext sc) {
    The bean's remote home interface :
    package converter;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBHome;
    public interface ConverterHome extends EJBHome {
    Converter create() throws RemoteException, CreateException;
    The bean's remote interface:
    package converter;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.math.*;
    public interface Converter extends EJBObject {
    public BigDecimal dollarToYen(BigDecimal dollars) throws RemoteException;
    public BigDecimal yenToEuro(BigDecimal yen) throws RemoteException;
    The j2ee application client:
    import converter.Converter;
    import converter.ConverterHome;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.math.BigDecimal;
    public class ConverterClient {
    public static void main(String[] args) {
    try {
    Context initial = new InitialContext();
    System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                   System.setProperty("java.naming.provider.url","jnp://10.144.97.250:3700");
    Context myEnv = (Context) initial.lookup("java:comp/env");
    Object objref = myEnv.lookup("ejb/SimpleConverter");
    ConverterHome home =
    (ConverterHome) PortableRemoteObject.narrow(objref,
    ConverterHome.class);
    Converter currencyConverter = home.create();
    BigDecimal param = new BigDecimal("100.00");
    BigDecimal amount = currencyConverter.dollarToYen(param);
    System.out.println(amount);
    amount = currencyConverter.yenToEuro(param);
    System.out.println(amount);
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    }

    Surprisingly I find an upsurge in the number of posts with this same problem. I recently found a post which gave a nice link for this. Follow the steps and it should help:
    http://docs.sun.com/source/819-0079/dgacc.html#wp1022105

  • Problem to start the java stack . its not kernel. its java stack CAF

    Hello SAP,
    We have a problem to start the java stack. We saw in the SAP
    Managementconsole that the instances are running,
    The problem began after the deployment of the sap.com/CAF increaseing
    from patch 6 to 12. After that we make the update from 12 to 12.1
    The current kernel is number 95, the latest one.
    This plattform is Netweaver 04‘S.
    The B2C applications are stopped
    We hope you help us as soon as possible , because we are getting late
    with the project.
    My email:
    [email protected],
    ***send me and email and I can send you the files:
    *error in java stack.doc  (detail of the error)
    *the directory work
    *and the log file of the SDM is attached in the file information_log_SDM.txt
    The log file of de E:\usr\sap\CRD\DVEBMGS01\SDM\program\log
    is also attached in the file sdmcl20070716142953.log
    thanks for your fast answer
    Best Regards,
    Luis Moreno

    aply the note: 1010640 and later restart the system
    Luis Moreno

  • Error when I deployed the java EAR application in NWDS 7.1

    HI All,
    I got the  error when I deployed the java EAR application in NWDS 7.1 version..help me out...........................................
    com.sap.ide.eclipse.deployer.api.APIException: DeployException,cause=[ERROR CODE DPL.DCAPI.1023] AuthorizationException.
    Reason: , An error occurred during the deployer retrieval. Cause =[ERROR CODE DPL.DC.3151] The user LJ4PJW could not be authorized, because doesn't own the (com.sap.engine.interfaces.security.ServiceAccessPermission dc) permission for deploy controller. at com.sap.ide.eclipse.deployer.dc.ComponentManagerImpl.getDeployProcessor(ComponentManagerImpl.java:62)
    Thanks
    Costa

    The user LJ4PJW could not be authorized, *because doesn't own the* (com.sap.engine.interfaces.security.ServiceAccessPermission dc) *permission for deploy controller. a*t com.sap.ide.eclipse.deployer.dc.ComponentManagerImpl.getDeployProcessor(ComponentManagerImpl.java:62)
    The user is not have proper authorizations. Use some other administrators user id which has all admin roles and authorizations assigned and try to deploy.
    Regards,
    Ravi

  • Error: The Java Runtime in use does not contain a suitable JAXP feature

    Hi,
    I'm trying to get Eclipse TPTP to work. One of the steps I need to execute is to run a setConfig.bat file. When I ran it, I got the following error:
    ERROR: The Java Runtime in use does not contain a suitable JAXP feature
    RESOLUTION: Use a JRE which supports the JAXP featureI use Eclipse Europa, and it is using my JDK (actually JRE) 1.6.0_05. That should mean I have JAXP in my JRE (which is confirmed when I search on JAXP from the directory C:\Program Files\Java containing jdk1.6.5_05 and jre1.6.5_05 directories).
    Is there something extra I need to do to let Eclipse and TPTP find my JAXP classes?
    TIA,
    Abel

    Hi,
    Even i am getting the same error but i use JRE 1.5.0_14. please let me know if you happen to resolve this.
    Thanks in Advance,
    Sai

  • Problem with running the midlet class (Error with Installation suite )

    hi everyone...
    i have problem with running the midlet class(BluetoothChatMIDlet.java)
    it keep showing me the same kind of error in the output pane of netbeans...
    which is:
    Installing suite from: http://127.0.0.1:49296/Chat.jad
    [WARN] [rms     ] javacall_file_open: wopen failed for: C:\Users\user\javame-sdk\3.0\work\0\appdb\delete_notify.dat
    i also did some research on this but due to lack of forum that discussing about this,im end up no where..
    from my research i also find out that some of the developer make a changes in class properties..
    where they check the SIGN DISTRIBUTION...and also change the ALIAS to UNTRUSTED..after that,click the EXPORT KEY INTO JAVA ME SDK,PLATFORM,EMULATOR...
    i did that but also didnt work out..
    could any1 teach me how to fix it...
    thanx in advance... :)

    actually, i do my FYP on bluetooth chatting...
    and there will be more than two emulators running at the same time..
    one of my frens said that if u want to run more than one emulator u just simply click on run button..
    and it will appear on the screen..

  • Getting an error msg while trying to run the java class from CMC

    Hi All,
    I am getting an error, while trying to run the java .class file, that which is imoported into CMC.
    Error msg:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at com.crystaldecisions.sdk.plugin.desktop.program.internal.ProgramWrapper.main(ProgramWrapper.java:49)
    I have imported .class file into CMC and trying to invoke the .class file by another java program from eclipse..When i tried to invoke the .class in cmc, i am getting an error msg, mentioned above. I thought there might be version conflict. So i changed the java complier version to 1.5 in my Eclipse. After that is done again i am facing the same problem.
    Can anyone help me to resolve this issue?
    Thanks in Advance.

    i have installed BO SDK 3.1 , Service pack 3. It comes woth JDK 1.5 version. i have not done any chnages to it. I impoprted all the jar files related to BO into eclipse.
    1)  Actually, i am writing java code on eclipse. When i run code from the eclipse, it creates a session to cmc and creates folder structure what i need.
    2)  But the thing is, that code needs to run, when i import the .class file into cmc. The process how i imported the .class file to cmc.
    Manage> Add> Program File-->Java (Check Box). In this way i added java class file from the eclipse workspace (class file from the bin directory).
    3) So when i run the .class file externally by another java program or also when i log in to CMC and run that .class file, the instance shows sucess, but when i see the logfile i am getting an exception that which i mentioned above.
    If my method is worng can you please let me know the stepts how to run java program in cmc.
    Thanks in Advance

  • Why the constructor of the base class calls first when u run the java app.

    why the constructor of the base class calls first when u run the java application

    For the record the other very exciting questions are:
    pls give the differences between application server and web server with examples
    will u pls narrate the differences between servlet context and servlet config.....
    where can we find servlet config...
    is there any methods to access servlet config

  • I am taking courses online and the newer version of firefox 4.0 isn't compatible with the java, which I use on my web page. And I need to go back to the older version of 3.614. How do I reverse to what I had before?

    I need to get another version of firefox other than 4.0. due to the version not compatible or is unknown to the java I'm using on my web for online classes.

    You might try using the add-on 'NoSquint' which allows numerous zoom options specific to each page you visit & keeps your settings - https://addons.mozilla.org/en-US/firefox/addon/nosquint/
    If you want to go back to 3.6x, you will find it here:
    http://www.mozilla.com/en-US/firefox/all-older.html
    In most cases you can simply "upgrade" (meaning downgrade) directly from the installation. It would be a good idea to save your passwords & bookmarks just to be on the safe side.

  • Call the ess payslip application using a URL

    Hi
    i want to
    1. call the ess payslip application using a URL
    2. and pass PERNR as parameter to this URL so that the salary slip displayed is for that particular PERNR.
    i am able to get the payslip application through URL.
    Now how to acheive point no. 2 ?
    Regards
    Rajendra
    Edited by: Rajendrakumar Gaikwad on Dec 30, 2008 11:55 AM

    Hello
    If this is not possible , let me know which BAPI it is calling to create the pdf
    so that i will create a application to call the BAPI itself and pass PERNR .
    Regards
    Rajendra

  • Is it possible to run the java program without main?

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    Ramya

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    RamyaWhy do you ask? It sounds like an odd question. Your program can be an applet and it doesn't need a main method in that case.
    Kaj

Maybe you are looking for

  • BPM - doubt in N:1 mapping of IDOCs

    Is there any DETAILED document on Mapping multiple Idocs into a single Idoc package using BPM.My doubt is in the latter part in this process(During Receiver Determination) : Scenario : CRM->XI->R3 We will download the CREMAS03 and then make changes i

  • OBIEE 10G count distinct problem

    Hi, I am really new to OBI now runs into this problem. I have a fact and three dimension tables as follows: fact: 1. sales: sold_vlaue (sum) transactions (count distinct receipt_id) branch_id (foreign key) daykey (foreign key) receipt_id (foreign key

  • Activation error due to the missing objects in shadow instance.

    Hello All, We have problem with our NW701 -> NW730 upgrade. In phase ACT_UPG there is problem with activation of two tables -> 1EEDO519 "Table" "/BI0/PRSTT_EID" could not be activated 1EEDO519 "Table" "/BI0/PRSTT_OBJNM" could not be activated The pro

  • Amount printing problem

    Dear All, I am having a problem in printing the amount in words in smartform which is created in arabic as its original language , The problem is descriped below. The invoice say 34000.000  is priniting as thirty four thousand. But if the invoice amo

  • "this person cannot be reached by imessage at this time"

    "this person cannot be reached by imessage at this time"