Compiling C++ classes on Linux

Thanks in advance for your help!
I'm trying to compile a C++ class (that calls another class) with JNI. It compiles but the functions don't seem to be in the .o file.
The HelloWorld example runs fine.
Any ideas?

Did have a long, detailed message, but it didn't post, for some reason.
There's a class written in C++ which I want to use, Token. I have a wrapper Java class, Tokenizer. The Tokenizer C++ class I defined holds a Token object, as a data member.
When running java, the .so is found, but the method isn't, what I get is:
UnsatisfiedLinkError: getType
so I checked the shared library file, and the method doesn't show in it:
nm -s libtoken.so
... <methods from Token, not Tokenizer>
I tried also:
nm -s tokenizer.o
00000000 t gcc2_compiled.
When running
nm -s token.o, I get the full list of methods.
I just noticed, the C++ class and ata members are defined in the .h file. Am I supposed to define the class and data members in the generated .h file?
Here is the compilation process:
g++ -c -I/usr/local/java/jdk1.3/include -I/usr/local/java/jdk1.3/include/linux token.cc
g++ -c -I/usr/local/java/jdk1.3/include
-I/usr/local/java/jdk1.3/include/linux tokenizer.cc
ld -shared -o libtoken.so token.o tokenizer.o
java -Djava.library.path=.:/usr/local/java/jdk1.3/lib/i386/:/usr/local/lib ex3 symboltableitem.cmm
Exception in thread "main" java.lang.UnsatisfiedLinkError: getType
at Tokenizer.getType(Native Method)
at Parser.declaration(Parser.java:69)
at Parser.declaration(Parser.java:42)
at ex3.main(ex3.java:33)
Tried also compiling this way, and then Java doesn't find 'main':
g++ -I/usr/local/java/jdk1.3/include -I/usr/local/java/jdk1.3/include/linux token.cc tokenizer.cc -Xlinker -G -o libtoken.so
java -Djava.library.path=.:/usr/local/java/jdk1.3/lib/i386/:/usr/local/lib ex3 symboltableitem.cmm
Exception in thread "main" java.lang.UnsatisfiedLinkError: /a/fs-01/grad/amigo/Compilers/Ex3/libtoken.so: /a/fs-01/grad/amigo/Compilers/Ex3/libtoken.so: undefin
ed symbol: main
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1382)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
at java.lang.Runtime.loadLibrary0(Runtime.java:749)
at java.lang.System.loadLibrary(System.java:820)
at ex3.main(ex3.java:22)
I'm just about to give up and re-write the class in Java. But that's not what JNI is supposed to do :)
Thanks,
ami

Similar Messages

  • Compiling Nested Classes and Interfaces

    I am looking for documentation about compiling nested classes and interfaces. I have found something in the JVM Specification, but there does not explain how a nested class is compiled and what is included in the top level class to mark a "place holder" to the nested class. The JVM Specification in this topic cite the web page http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html that does not exists any more.
    My root problem is that: I am compiling a class with a private nested class, but in the class file generated TopLevelClass$NestedClass.class the class does not have the private modifier. So I am not understanding why the "private" modifier was removed during compilation.
    I performed the same test with a protected nested class and the result was the nested class with the public modifier. So I am not understanding why the "protected" modifier was changed to "public".
    Thanks in advance,
    Mardoqueu.

    This should not be happening. What compiler are you using? If it's a reasonably recent Sun compiler, could you post a minimal example?

  • Cannot compile two classes that are on same package

    When I compile two classes that are on same package one class that is independent of other class gets compiled but the other class which uses
    the first one shows cannot find symbol error with the first class name

    try...
    javac *.java
    that should compile all the java files in that folder at the same time. I dont know if that will fix your problem but it is worth a shot.

  • Java.lang symbols not found when compiling package classes

    I have a set of classes that I have wrapped up in a package. The package name and
    directory structure follow the standard required for each. These classes contain many
    java.lang.Math functions and java.lang.Double calls.
    Am I correct in that the java.lang functions will be imported automatically? When I
    compile a class that is in the package, it looks for the Math.pow (for example)
    function in the package instead of java.lang. I have tried putting the following include
    at the top:
    include java.lang.*;and I still get the "cannot resolve symbol" error. Only when I use
    include java.lang.Math;
    include java.lang.Double;does it compile properly. Is this indicative of a problem with my classpath? It is
    currently set to look in whatever the current directory is, the directory with src.jar,
    and my dev directory that contains the package I am working on.
    Please advise! Thanks in advance!
    Rodman

    Thanks for the quick reply! I looked in the package directory and found the Math.java and
    Double.java files. I'm not sure why they were there. Thanks again!

  • Suffering an complie error when trying to compile java class in EBS11i

    Hi,
    When I trying to compile java classes with which imported the HttpServletResponse class, will get the follow error message:
    package javax.servlet does not exist
    cannot resolve symbol
    symbol : class HttpServletResponse
    It seems the javax.servlet package is not included in the classpath. But I checked the $CLASSPATH, it seems no problem.
    echo $CLASSPATH
    /u02/applvis/viscomn/util/java/1.4/j2sdk1.4.2_04/lib/tools.jar:/u02/applvis/viscomn/util/java/1.4/j2sdk1.4.2_04/lib/dt.jar:/u02/applvis/viscomn/util/java/1.4/j2sdk1.4.2_04/jre/lib/charsets.jar:/u02/applvis/viscomn/util/java/1.4/j2sdk1.4.2_04/jre/lib/rt.jar:/u02/applvis/viscomn/java/appsborg2.zip:/u02/applvis/visora/8.0.6/forms60/java:/u02/applvis/viscomn/java
    Does anyone know the reason?
    environment: ebs 11i
    Thanks&Regards,
    Xiaofeng

    resolved this issue.
    1. Edit $APPL_TOP/admin/adovars.env file -
    Add the following jar files to the AF_CLASSPATH line -
    Full path of /...../iAS/Apache/Jsdk/lib/jsdk.jar
    Full path of /...../iAS/Apache/Jserv/libexec/ApacheJServ.jar
    2. Bounce the concurrent manager in order to have the changes take effect.

  • Compile Error: 'class' or 'interface' expected

    Hi all,
    I have a code which was compiling/running successfully:
    import java.net.*;
    code
    When I added the line: import java.io.*;
    import java.net.*;
    import java.io.*;
    code
    Got the following compile error:
    'class' or 'interface' expected
    import java.io.*;
    ^
    If I comment one of my import statements then it compiles, but I can't have both!
    Does anybody know what's the problem? where it comes from?
    Any help is greatly appreciated.

    I haven't post the entire code b/c it's very long, anyway here it is...
    import java.net.*; ;
    import java.io.*;
    //class TransactionOp: #1
    class TransactionOp
    int ID = 0;
    double price = 0.0;
    int subsID = 0;
    String xmlDoc = "";
    String xmlResp = "";
    String respID = "";
    String authCode = "";
    int opResult = 0;
    public TransactionOp(int anID, double aPrice, int aSubID)
         ID = anID;
         price = aPrice;
         subsID = aSubID;     
         //op done values: 1: REF, 2: DCL, 3: AUTH, 4: AUTH_NoID
         //op errors: -1: noResponse, -2: noAuthResp, -3: noStatus, -4: no gw.
    //class AddressCC: #2
    class AddressCC
    String zipcode = "";
    String city = "";
    String state = "";
    String country = "";
    String address1 = "";
    public AddressCC(String addr1, String city1, String state1, String country1, String zipcode1)
         address1 = addr1;
         city = city1;
         state = state1;
         country = country1;
         zipcode = zipcode1;
    //class InfoCC: #3
    class InfoCC
    String fullName = "";
    String number = "";
    String expDate = "";
    public InfoCC(String name, String number1, String date)
         fullName = name;
         number = number1;
         expDate = date;
    public class SurePayGW
    //instance fields
    private String merchant = "";//merchant = aMode
    private String password = "";
    private String server = "";
    private int subsID = 0;
    public SurePayGW()
         merchant = "34593";
         password = "hnbv78hj6";
         server = "xml.surepay.com";     
    }//endof constructor:SurePayGW
    //String formattedS = "\"" + s + "\"";
    public void spitDoc(SurePayGW sp, AddressCC address, InfoCC ccInfo, TransactionOp trans)
         String xmlBuf = "<!DOCTYPE pp.request PUBLIC \"-//IMALL//DTD PUREPAYMENTS 1.0//EN\" \"http://www.purepayments.com/dtd/purepayments.dtd\">";     
         xmlBuf = xmlBuf + "<pp.request merchant=" + "\"" + sp.merchant+ "\" password=" + "\"" + sp.password+ "\">";
         xmlBuf = xmlBuf + "<pp.auth ecommerce=\"true\" ordernumber=" + "\"" + trans.ID + "\" recurring=\"false\">";     
         xmlBuf = xmlBuf + "<pp.creditcard number=" + "\"" + ccInfo.number + "\" expiration=" + "\"" + ccInfo.expDate.charAt(0) + ccInfo.expDate.charAt(1)+ "/" + ccInfo.expDate.charAt(2) + ccInfo.expDate.charAt(3) + "\">";          
         xmlBuf = xmlBuf + "<pp.address type=\"billing\" zip=" + "\"" + address.zipcode + "\" city=" + "\"" + address.city + "\" state=" + "\"" + address.state + "\" country=" + "\"" + address.country + "\" fullname=" + "\"" + ccInfo.fullName + "\" address1=" + "\"" + address.address1 + "\"/>";
         xmlBuf = xmlBuf + "</pp.creditcard>";     
         xmlBuf = xmlBuf + "<pp.address type=\"shipping\" zip=" + "\"" + address.zipcode + "\" city=" + "\"" + address.city + "\" state=" + "\"" + address.state + "\" country=" + "\"" + address.country + "\" fullname=" + "\"" + ccInfo.fullName + "\" address1=" + "\"" + address.address1 + "\"/>";     
         xmlBuf = xmlBuf + "<pp.lineitem sku=\"R" + trans.subsID + "Zg\" description=\"Subscription Renewal\" taxrate=\"0\" quantity=\"1\" unitprice=\"" + trans.price + "USD\"/>";
         xmlBuf = xmlBuf + "</pp.auth></pp.request>";
         //print("@DBG [SurePayDoc.submitTransaction]: will send %s" % xmlBuf)
         trans.xmlDoc= xmlBuf;
         //System.out.println("This the final result of xmlBuf: ");
         //System.out.println(xmlBuf);
         //System.out.println("trans.xmlDoc = " + trans.xmlDoc);
    }//endof m: spitDoc
    public void submitTransaction(SurePayGW sp, TransactionOp aTrans)
         String param = "";
         HttpURLConnection connection;
         URL url;
         String urlString = "";
         String input = "";
         String response = "";
         try
              //params= urllib.urlencode({'xml' : aTrans.xmlDoc})
              param = java.net.URLEncoder.encode(aTrans.xmlDoc, "UTF-8");
              //System.out.println("The output from java.net.URLEncoder.encode: " + param);
              //link= httplib.HTTPSConnection(self.server)
              urlString = "https://" + sp.server;
              url = new URL(urlString);
              connection = (HttpURLConnection)url.openConnection();          
              System.out.println(connection.getURL());          
              System.out.println(connection.getResponseCode() + " " + connection.getResponseMessage());          
              System.out.println(connection.getURL());
              connection.setDoInput(true);
              connection.setDoOutput(true);
              connection.setUseCaches(false);
              //link.putrequest('POST', '/')
         connection.setRequestMethod("POST");
              //link.putheader('Content-type', 'application/x-www-form-urlencoded')
              //link.putheader('Content-length', ("%d" % len(params)))
              //link.putheader('Accept', 'text/plain')
              connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
              connection.setRequestProperty("Content-length", param.length());
              connection.setRequestProperty("Accept", "text/plain");
              //link.endheaders()
              connection.connect();
              System.out.println("Client : Connected");
              //link.send(params)
              //response= link.getresponse()
              //data= response.read()     
              DataOutputStream out = new DataOutputStream(connection.getOutputStream());
              System.out.println("Client : Writing Content");
              out.writeBytes(content);
              System.out.println("Client : Flushing Stream");
              out.flush();
              System.out.println("Client : Waiting for response from Server");
              BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
              System.out.println("Client : Opened input stream");
              while((input = in.readLine()) != null)
                   response += input + "\r";
              System.out.println("Client : received : "+response);
              //I'm not bothering to close the streams or http connection yet.
         }//endof: try
         catch (MalformedURLException e)
              e.printStackTrace();
         catch (Exception e)
              e.printStackTrace();
    }//endof m:submitTransaction
    }//endof class:SurePayGW

  • How to re-compile the class after modification??

    Hello All,
    I found that in 'SearchResourceRenderer' Target window is hardcoded as "_blank". Now i have changed that to "_self" so that i can open the documents from the Search Results in the same frame.
    Please help me in re-compiling the class so that i can deploy it again onto the Portal.
    Regards
    Vaib

    Hi Vaib,
    as already told in the parallel thread:
    - Put the decompiled, changed class into a NWDS Java project.
    - Install and use ClassLocator to create the complete build path needed.
    - After the class doesn't show any more errors, it's compiled. Open the original JAR within the portal app directory with a hot replacement tool like WinRAR and drag and drop the class file into the JAR folder. Restart the server.
    The alternative is to import the whole PAR,  additionally to put the JARs into the PAR project, remove the class from the JAR where it comes from, recompile the changed decompiled class and then deploy the complete PAR into the portal. It's a bit more work but a more clean deployment.
    Hope it helps
    Detlev

  • Compiling Java Class in Workshop

    May I ask a dumm question: how to compile a java class in Workshop? Application
    Build or Project Build does not seem to do the work.
    Thanks.

    "Gerald Nunn" <[email protected]> wrote:
    "Jeff" <[email protected]> wrote in message
    news:406455b2$[email protected]..
    May I ask a dumm question: how to compile a java class in Workshop?Application
    Build or Project Build does not seem to do the work.Works fine for me, what type of project is the java file in?
    Gerald
    Thanks for the reply.
    It is a web project. My Java files are under the following folder tree:
    eSheetWeb\WEB-INF\classes
    I have run Build Project against eSheetWeb few times. No errors but java files
    just not getting compiled to class. Also is there a way to just compile without
    run the entire Build?

  • Compiling dependent classes

    I have three classes that are dependent on each other, that is class 1 utilizes objects of type class 2 and class 3, class 2 utilizes objects of type class 1 and class 3, and class 3 utilizes objects of type 1 and 2. I am wondering how to compile these classes. I know for the same situation in C++ this conflict is resloved through header files, since there is no header files in Java I am assuming there is compiler flag I can set, I tried the -soucepath flag but that doesn't seem to work. Any suggestions, I know I might be able to accomplish my goal using interfaces or abstract classes but I would really like to avoid using those. Any help would be appreciated.
    Thanks

    -sourcepath I believe should do it. What error message(s) did you get?
    But another approach is just to specify all three classes as arguments to javac, as in:
    javac Class1.java Class2.java Class3.java

  • Help compiling with .class files

    I am using JGrasp and I am trying to compile a program that uses .class files instead of the .java files, but JGrasp will not recognize these at compile time. How do I get my program to compile with these .class files?

    I prefer using Jenuity:
    [http://www.nmmu.ac.za/jenuityIDE]
    It's much simpler to use than JGrasp and isn't nearly as confusing.
    For the record, you compile .java files into .class files. There is no need to "compile" existing .class files. If you have the class files you can run them from the command line. e.g. if you have a class file named Orange.class you should be able to type "java Orange" from the command line to run it. If Orange is inside a directory structure based on packages you may need to execute this command from just outside the 'highest" folder.
    If you just need to link to these class files, copy them into the "/jre/lib/ext" folder of your JDK.

  • Ant or what tool to compile Java Classes

    For the past year I have been using Windows command window to compile Java Classes for my Servlets, Java Beans and Helper classes. I use Cold Fusion studio as my IDE for creating the Java classes. All of my Web Applications use MVC for Forms feeding small databases and I only have around 7 to 10 class files per Web application.
    Should I start to use Ant and/or what is recommended so I can keep up with current technology instead of using Windows Command Window to compile my Java classes?

    Try the following link.
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/cfc19866-0401-0010-35b2-dc8158247fb6
    The download in the above link has NWDS and portal as well. Unzip the file and install NWDS studio.

  • Unable to compile java classes in NWDS- "JSPDynPage cannot be resolved "

    Hi All,
    I am trying to write small JSPDynaPage when i am getting following complilation error in my Java classess.
    1) "PageProcessorComponent cannot be resolved or is not a valid superclass"
    2) "JSPDynPage cannot be resolved or is not a valid superclass"
    I did check for the existance of
    com.sap.portal.htmlbbridge.jar & prtapi.jar which is present in my C:\NetWeaverDevStudio\eclipse\plugins\com.sap.ep.applicationDevelopment and
    ECLIPSE_HOME=C:/NetWeaverDevStudio/eclipse but for some reason i am unable to compile my classes. Please help me to resolve this issue.
    Thanks,
    Manju

    Try the following link.
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/cfc19866-0401-0010-35b2-dc8158247fb6
    The download in the above link has NWDS and portal as well. Unzip the file and install NWDS studio.

  • Errors while trying to compile rdf file on LINUX

    hi all,
    We are trying to compile rdf file on linux using this command line:
    $ORACLE_HOME/bin/rwconverter.sh userid=scott/tiger@dbname batch=no source=test.rdf stype=rdffile dtype=repfile overwrite=yes.
    The following errors occured:
    REP-0004: Warning: Unable to open user preference file.
    REP-3000: Internal error starting Oracle Toolkit.
    What's the problem!
    plz help.

    Hi,
    These Metalink (http://metalink.oracle.com) notes might help you:
    210795.1 : Troubleshooting Guide for REP-4 error
    200474.1 : Comprehensive REP-3000 Troubleshooting and Overview Guide
    Navneet.

  • Compiling a class, help.

    I am having trouble compiling a class file on my server. I have been given the path for the Java Compiler but I am so new to telnetting and unix.
    The path that I have been given is usr/local/java/bin/ to use the Java Compiler. I have tried a lot of different strings, but I can't seem to get it to work.
    This is the code that I want to use: usr/local/java/bin/javac -classpath %CLASSPATH%;C:/usr251/home/obetz/public_html/servlets/mail.jar
    Does that look write? What is the string I want to use when I telnet into my account if I want to compile my java file into a class?

    Please bear with me. I'm really new to Unix. I've got a couple of jar & java files already in the classpath. Here is where they are:
    /usr251/home/obetz/public_html/servlets/
    MailerBean.java and mail.jar
    This is what i tried to use to compile the mail.jar file:
    /usr/local/java/bin/javac /usr251/home/obetz/public_html/servlets/mail.jar
    The error is invalid option or arguement. I also tried it with -classpath in the middle, omitting the $CLASSPATH and still nothing.

  • Is it possible to compile/convert class/jars to DLL?

    Hi all,
    Is it possible to compile/convert class/jars to DLL so that my VB program can use it? If yes, how do i do it?
    thanks for your time.

    No it is not (afaik). But as far as the VB stuff goes, somebody who posted here earlier mentioned passing data to VB functions. Can't remember which post it was.
    One thing you can do is use sockets to send data between your Java code and VB application using sockets. Sockets are easy to use in Java, and in VB you just need to use the stuff in ws2_32.dll. You can find VB modules for sockets all over the place.
    Jason

Maybe you are looking for

  • HT1351 my ipod keeps on freezing and now it wont turn back on even if i try charging it what do i do?

         Hello I have a ipod nano 5th Gen and it keeps on freezing and powering off and I tried resetting it and charging it but it wont turn back on what do I do?

  • Threading in ABAP?

    I have a scenario (Order taking) where the execution logic takes considerable time to finish the processing. As a result, the end user who is using the web application has to wait for at-least 10 minutes till the processing is complete. In the UI (We

  • Help needed to access Oracle from Applet.

    Please help. I have spent days reading info on the web and I simply cannot access to Oracle from an applet to work. Oracle is on a different IP than the Web Server. For my testing I am running the html directly from my local file system. Here are the

  • How to control the movie player in iPhone SDK 2.0?

    Hello, everybody! With the third beta version of iPhone SDK I finally played a movie with the example from the manual. But I need to seek in the movie and control the playing process. With the MPMoviePlayerController class this is impossible, because

  • Code to create a folder in java

    Hi friends I want to know how to create a folder in java using files concept. Can any one send me the code to create a folder in our system using files concept. Thanks in advance.