Run java class using JBuilder

hi,
I already import the java class forder to the src folder in JBuilder where the src folder is created by the JBuilder itself. When i run compile the program there is an error in reading the java class file but when i run the program in Textpad, the program is success. May i know why? how can i run my program using java class in JBuilder instead of Java source? Thanks.

In JBuilder there is an option of specifying what the 'main' file in a project is . Specify that to this class file
[ What I mean is , in many java files we can define 'main' method , but we will intend to execute the main of one file only for a project . In JBuilder specify this file as the main class file ]

Similar Messages

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • How can i run Java class form  other java application.

    Hi ,
    I have problem to run java class from my java application,
    I am using the class ClassLoader in order to launched the Java class , it�s work fine whenever, the class exist in the same folder , however , when i am trying to run class that is not in the current folder ,
    i got error (see below),
    Do you have any idea what is wrong?
    java.lang.ClassNotFoundException
         at SimpleClassLoader.loadClass(SimpleClassLoader.java:110)
         at SimpleClassLoader.loadClass(SimpleClassLoader.java:53)
         at Run.main(Run.java:31)

    What does "run an class" mean? You don't run classes. They're not executables.
    I bet your problem is the classpath. You are aware that the classloader looks only there? Unless it's an UrlClassLoader.

  • Can anyone help i want to call java class using visual basic

    I want to call java class using visual basic and send some arguments to the main class

    Hi,
    I don't know VB, but you can surely launch a command line like :
    javaw.exe mypackage.MyMainClass myArgument1
    Regards

  • Urgent !!!!!!!!!!!! regarding CREATE JAVA CLASS USING BFILE

    We have Oracle 8.1.7 spatial database. We got to load some java classes into the database. We would like to make it as the java programs to be loaded from a client system into the oracle server. I am using CREATE DIRECTORY command to create a directory object (say suppose \\prav\loadjavaclasses\. Then using the CREATE OR REPLACE JAVA CLASS USING BFILE (object_name, 'CLASSNAME.CLASS'). This .class file is in the network identified by prav which in turn has a shared directory (full privileges) loadjavaclasses folder. Can you please help in this regard.
    Please mail me to [email protected]
    thanks in advance
    SudhaSrikanthan
    null

    use loadjava

  • Running stand alone java class using Maven

    Hi I want to run my main class using Maven.Can anyone help?

    SDET wrote:
    Hi I want to run my main class using Maven.Can anyone help?I'm pretty sure the Maven documentation can be of great help. If not, the Maven-users mailing list is your resource of choice for Maven related questions.

  • Synchronized method in a java class used by many interfaces

    My interface (idoc to file) is using a java class, which has one method that reads a table from a central database and after doing some calculations updates it.
    (The interface instantiate the class inside a user-defined function and calls the method there.)
    The problem is that if somebody sends 100 idocs at the same time, there can be a “dirty read”, I mean, a read just before other interface updates the table.
    We want the following:
    Interface 1:
    -          Read counter from the table (counter = 5 )
    -          Increment counter (counter = 6)
    -          Update table with that counter (table with counter = 6)
    Interface 2:
    -          Read counter from the table (counter = 6 )
    -          Increment counter (counter = 7)
    -          Update table with that counter (table with counter = 7)
    RESULT: The table has the counter = 7
    But what is happening is the following:
    -          Interface 1 reads (counter = 5)
    -          Interface 2 reads (counter = 5)
    -          Interface 1 increments counter (counter = 6)
    -          Interface 2 increments counter (counter = 6)
    -          Interface 1 updates table (table with counter = 6)
    -          Interface 2 updates table (table with counter = 6)
    RESULT: The table has the counter = 6 (WRONG)
    I made the method synchronized. What I was expecting was that only one interface (i1) could enter the method (read the table and update it) while other interfaces running at the same time would have to wait until i1 finished that method.
    My first test indicates that's not happening. Can anybody help me to find a solution?

    Hi Bhavesh,
    If the QOS is EOIO this means that the integration engine manage the call to the mapping program (and all the other blocks) inside an "internal" synchronized method.
    So this means that in this case you do not need to manage the queued access (synchronization) inside your custom java code because it is already enveloped in a queued block by XI.
    The problem that Jorge had can be easily reproduced using the sample code that follows:
    <b>class Synch Object</b>
    import java.util.Date;
    public class SynchObject {
         String strName;
         public SynchObject(String strName){
              this.strName = strName;
         public synchronized void syncWrite(String strCaller) throws InterruptedException{
              Date now;
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " " + strCaller + " entering syncWrite of " + strName);
              System.out.flush();
              Thread.sleep(1000);
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " syncWrite of " + strName + " called by " + strCaller );
              System.out.flush();
              Thread.sleep(1000);
              now = new Date();
              System.out.println("-- " + now.toLocaleString() + " " + strCaller + " leaving syncWrite of " + strName);
              System.out.println("");
              System.out.flush();
    <b>class Caller</b>
    public class Caller implements Runnable {
         String strName;
         SynchObject target;
         int intMax;
         public Caller(String strName, SynchObject target, int intMax) {
              this.strName = strName;
              this.target = target;
              this.intMax = intMax;
         public void run() {
              for(int i=0; i<intMax;i++)
                   try {
                        target.syncWrite(strName);
                   } catch (InterruptedException e) {
                        e.printStackTrace();
    <b>class Workbench</b>
    public class Workbench {
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SynchObject sObj1 = new SynchObject("syncObj1");
              SynchObject sObj2 = new SynchObject("syncObj2");
              Caller c1 = new Caller("caller1",sObj1,2);
              Caller c2 = new Caller("caller2",sObj1,2); '[*CHANGE*]
              Thread ct1 = new Thread(c1);
              Thread ct2 = new Thread(c2);
              ct1.start();
              ct2.start();
    Run the workbench class to see what happen when setting QOS EOIO (the synch object is the same).
    To see instead what happen now (missing synchronization) you have to change in Workbench class the statement
    Caller c2 = new Caller("caller2",sObj1,2); '[*CHANGE*]
    with
    Caller c2 = new Caller("caller2",sObj2,2); '[*CHANGE*]
    The reason is that every instance of the mapping program declare a new instance of the "Synchronized object" so the calls are synchronized inside the same mapping program but not between several mapping program.
    Hope this give you a better idea on this problems with java synchronization, but if you have further doubts (I know it's a little bit tricky ) feel free to ask.
    Kind Regards,
    Sergio

  • Problems Creating a Java Class using a webservice with certificate

    hi,
    i'm developing a java class that call's a webservice that needs a certificate, i'm not used to work with java, last time was 10 years ago, so i'm having some troubles because of the certificate.
    I already add the certificate using java control panel > Security > Certificates. When testing i get the following error: IOException (java.io.IOException: subject key, Unknown key spec)
    I think I need to define the certificate in my class, but i'm having a lots of trouble with the samples that i found over the internet, nothing works and i'm running out of time.
    This is my Class
    create or replace and compile java source named "FishInfoAt" as
    import java.net.*;
    import java.io.*;
    import java.security.*;
    public class FishInfoAt
         public FishInfoAt()
         public static String send(String urlfishinfoat, String mensagem, String mensagem1, String mensagem2, String mensagem3)
              // Init
              String response = "";
              String msgtotal = mensagem+mensagem1+mensagem2+mensagem3;
              String a = "";
              HttpURLConnection conn = null;
              try{
                   URL url = new URL(urlfishinfoat);
                   conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestMethod("POST");
                   conn.setRequestProperty("Content-type", "text/xml; charset=utf-8");
                   conn.setRequestProperty("SOAPAction", "https://servicos.portaldasfinancas.gov.pt:401/sgdtws/documentosTransporte/");
                   conn.setRequestProperty("Content-Length","" + msgtotal.length());
                   conn.setDoOutput(true);
                   conn.setDoInput(true);
                   conn.connect();
                   OutputStream out = conn.getOutputStream();
                   out.write(msgtotal.getBytes());
                   out.flush();
                   InputStream in = conn.getInputStream();
                   int value;
                   while( (value = in.read()) != -1)
                        response+=(char)value;
              catch(Exception e)
    response = ("*** ERROR - IOException (" + e.getMessage() + a + ")");
    return response;
    /

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

  • Accessing Java Class using JNDI

    Hi,
    I am looking for a way for accessing a java class (non-ejb) and invoking a method in it using JNDI.
    Thanks

    See if the follwing helps u
    1).implement Referencable interface for your java class. Implement serialize interface also.
    2).Referencable interface has a methd referencable() which will be invoked by JNDI naming system when a lookup is made by client.
    3) in referencable method create a Refrence object.(Reference is a api class).This Reference object can be created to contain a lot of info about the remote obj u have registered. In that u can say the class that be used to create your client side stub.
    4).now when client does a lookup, jndi creates a stub using Reference object and sends it to client.
    5)the methods now u call gets passed on to actual machine running ur remote object

  • How run java class on Mac Os X

    i develope java appliction and run it on windows platform and now i need run it on Mac Os X but i am new user for Mac Os X and i dont know how i can open Unix shell to compile and run my classes and i dont need to use any tool to make this task.
    thanks
    rabab

    The Terminal Application is in Utilities in Applications. You can use this to open your Unix shell. From there, you should be able to compile and run your java applications.

  • Running java classes

    I am a newbie to java and have installed the sdk files fine and breezyswing and terminal IO packages and it all seems to work ok because i can compile all my files fine. Even the test files i can compile and they work ok. But when i go to run the class file i always get this error
    Exception in thread "main" java.lang.NoClassDefFoundError: c:\Division.class
    can someone please help me.

    You might want to check this link.
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
    The argument to the java.exe command is a class name, not a file or path. If your class is defined as "public class Division" then the command is "java Division" Also, class names are case sensitive, so you must use Division, not division.
    If you still get the NoClassDefFound error, you probably have a Classpath problem. Try to CD to the directory where Division.class file is and use the command "java -claspath . Division"
    Then check the hundreds of posts in the forum concerning classpath.

  • How to run java .class file?

    How can i run/view .class file in java?. is there tool/utilities in java that can do that.?. Thanks

    Ednut wrote:
    I'm sure you must have been taught using the command: java yourClassName after navigating to the location of your compiled class in the command prompt.I'm sure the OP does not need condescending remarks from someone who knows almost as little Java as s/he does.

  • Running java class in command line

    Hi.. i have a java class i want to run from the command line. the problem is that when i do, i get this exception:
    Exception in thread "main" java.lang.NoClassDefFoundError: (class name)
    The class uses some jars, so i used the -classpath option, and seperated the jars with ":".
    I read in a previous topic that the solution can be to add the JRE1.5.0 to the path.
    Can anyone tell me the syntax to do that? And if anyone has a different solution can they tell me? Im running it on linux debian.
    Thx.

    It sounds like you only have the jars in the -classpath option. If that's right, then java will only look in those jars for classes. You probably need for example .:jar1.jar:jar2.jar if you want java to look in the current directory as well as the jar files for classes.

  • How to Transport Java Classes used in Mapping?

    Hi XI experts,
    Within the development of one message mapping, some external  java classes are imported and used in my UDF(user defined function). My question is: how will these external java classes be transported to the QA/PRD system? If I choose to use the file system transport method, do I have to manually find these jar files and transport them separately?
    Any comments or suggestions are highly appreciated.
    Thanks in advance
    Luis

    Hi Luis,
    Normally Mapping programs and External Jars are used in XI using Imported Archive. So this Imported archive once activated will become part of your SWCV and can be transported automatically with the SWCV.
    You dont have to worry about transporting it seperately, it will be avilable once you transport your SWCV using File system transport.
    Hope this helps,
    Regards,
    Ananth

  • Trying to run java class files from my jsp

    I am having difficulty running java files from my jsp. I have compiled my two java classes and inserted them onto my server in the webapps/WEB-INF/classes/scripting directory and have imported scripting.* into my jsp page. The files both compiled ok before the class files were loaded onto the server but when I rty to run the jsp from the server, I keep getting a compiler error. Thanks in advance
    Iob

    Here are the few question
    1) Does your java classes which u created is declared under package scripting. *.class files are to be places under the WEB-INF/classes directory only. Not under scripting. But if you java classes say are under a package called a.b. Then you need to put under classes\a\b\.

Maybe you are looking for