Compilation and System.loadLibrary

Hi everybody,
I'm pretty sure this will be the last time I talk about System.loadLibrary issues. This is definitely just a concept question, no code or JNI needed.
I have a call to System.load library like this:
System.loadLibrary( "Class" );
and then directly after that, a I call a constructor for the class:
Class c = new Class( params );
The problem is, though, that the code won't compile. I know the constructor is right, and I've looked at the System.loadLibrary documentation, and I can't figure out what the problem is. I know System.loadLibrary is a runtime event, and I'm using Eclipse, if that makes any difference.
So, I guess here comes the question finally. How can I make the compiler realize that the class I'm loading with System.loadLibrary is legitimate, so it doesn't give me a compiler error?
Thanks,
Jezzica85

jezzica85 wrote:
Oh, I'm sorry. That was just a general example, and yes, "Class" was just a fill-in for what I actually named the class, and "params" a fill-in for the parameters. I figured the specifics weren't important. I guess I should have made that example clearer.
Jezzica85I just wanted to make sure.
So, you have a class called whatever you have there in your classpath, and you've verified that it has a public constructor with the same parameters that you have given it? If both those statements are true then I don't see how you can have a compiler error involving the ctor - please post a copy and paste of the exact compiler error message.

Similar Messages

  • System.loadLibrary() conflict beetwen C++ and GCC

    Hallow.
    When I try to compilate a C library that uses a C++ class with the GCC (GNU) compiler it doens't recognize the class. ok!
    But, when I complile the same C library using the C++ (GNU) compiler, the 'System.loadLibrary()' does not find the library.
    What should I do?

    The symbols that are generated for C and C++ will be different because of name mangling that occurs for C++ symbols. System.loadLibrary will give an error because it will not find the symbol it expected to find. In the header file for the C library, can you try putting in the following lines :
    Before all the function definitions :
    #ifdef __cplusplus
    extern "C" {
    #endif
    After the function definitions :
    #ifdef __cplusplus
    #endif
    This will force the g++ compiler to not mangle the names of the C functions.
    hth
    rahul

  • System.loadLibrary() and DLL manifest files

    Hi,
    Has anyone gotten Java WebStart working with VisualStudio 2005 DLL manifest files? That is, it is illegal to load DLLs without having the manifest file visible. Last time I checked, Webstart did not extract native DLLs from JARs until System.loadLibrary() was used -- but this would not work for manifest files.
    The only workaround I can think of is embedding the manifest files inside the DLL but this sounds a bit ugly.
    A related problem is that if I System.loadLibrary() on library A and it depends on library B which I have never loaded before then this will fail because Webstart did not extract B.
    This is related to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6191612
    Any ideas?
    Gili

    The dll is
    deployed as part of a J2EE application, and shouldn't
    need registering by the regsvr32 program.regsvr32 should have nothing to do with JNI dlls. Unless the dll is also a COM object factory (or what ever the proper name for such a thing is), then regsvr32 should make no difference to its operation.
    >
    Can anyone explain the difference between the load()
    and loadLibrary() methods in detail?They do the same thing, except that for load() you specify the full path to the object and with loadLibrary() you just give its base name and the runtime tries to find it in the java.library.path after adding ".dll" to the name.
    You should only call one or the other. Calling both would be an error.

  • JNI System.loadLibrary troubles

    Hello again!
    I am so close to finishing this program I can taste it! But�
    OK, I am doing a bit of JNI. All appears to be well except my program can�t seem to use
    System.loadLibrary("myCPPdll");
    to find the dll file I need to run the C++ code.
    I�ve tired replacement with
    Runtime.getRuntime().loadLibrary("myCPPdll ");
    just for grins with the same result.
    I also tried
    System.loadLibrary("C:/fullPath/myCPPdll");
    with no luck.
    The error message I get, regardless if I run from the command line or via Eclipse is
    java.lang.UnsatisfiedLinkError: no myCPPdll in java.library.path.
    Possibly related: when I use the tutorial form
         Static
    System.loadLibrary("myCPPdll");
    my compiler tells me it can�t find the main. Just how critical is it to have it in this static format? It compiles great without the System call embedded in the static{} block!
    Thanks for your time!

    I added the .dll and get the same error. It was my
    understanding that System.loadLibrary(fileName)
    automatically added the file to the library path for
    the individual program in question. If this is not
    the case, could you please elaborate a bit on adding
    it to the path?
    No, in effect it searches the path to find the dll library. You need to (re-)read the tutorial -
    http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/step5.html

  • UnsatisfiedLinkError System.loadLibrary Windows CE JNI

    I am writing a java application for a Siemens SIMpad SL4 (Windows CE 3.0,Jeode EVM 1.9)
    I have a dll (mylib.dll) compiled with embedded visual c++ containing native functions.
    It is placed in the \windows directory.
    When I try to load the dll with System.loadLibrary(), I allways get an java.lang.UnsatisfiedLinkError.
    Things I have tried:
    System.loadLibrary("mylib");
    System.loadLibrary("mylib.dll");
    System.loadLibrary("\\windows\\mylib");
    System.loadLibrary("\\windows\\mylib.dll");
    java -Djava.library.path=\windows ...
    Different Directories for the dll (\windows, \, \windows\lib)
    Using other "CLASSPATH".
    Using other "PATH".
    But nothing worked.
    When I load a system dll (e.g. smartcard.dll) with System.loadLibrary("smartcard"), the dll
    is loaded succesfully. Only "self-compiled" libraries are not loaded.
    When I load the dll from a c++ test programm(HINSTANCE handle = LoadLibrary(L"mylib"))
    my library is loaded sucessfully.
    So it seems to be a java only problem.
    Any Ideas ?
    Thanks

    I tried to load different dlls with System.loadLibrary() and used the -verbose option of the jvm.
    A preinstalled dll: System.loadLibrary("winscard"); (Which has nothing to do at all with JNI)
    The "verbose" said: [Loaded Library \Windows\bin\winscard.dll]
    So the library seems to load succesfully.
    Another preinstalled dll: System.loadLibrary("finance");
    The "verbose" said: [Loaded Library \Windows\bin\finance.dll]
    The library loaded ok as well.
    A non exisiting dll: System.loadLibrary("nothing");
    The result was a "java.lang.UnsatisfiedLinkError nothing.dll; library not found"
    An empty test dll created with the dll wizard of embedded visual c++: System.loadLibrary("empty");
    (The dll is in the \Windows directory)
    The result was a "java.lang.UnsatisfiedLinkError empty.dll; library not found"
    A selfmade "JNI" dll: System.loadLibrary("mylib");
    The result is again a "java.lang.UnsatisfiedLinkError mylib.dll; library not found"
    So I don't think it's a problem with the method names.
    Thanks anyway.

  • How to Load 2 library files using System.loadLibrary in one .java file!!!

    Hello,
    Someone please help me. What I am trying to do is load two .DLL files in my program. Program works fine when I
    do the following way i.e. I have two .java files and in each I am loading one .DLL file. But I don't want to have
    two .java files I want to load both the .DLL files in one program.
    **************** Example.java **********
    import java.io.*;
    import java.util.*;
    public class Example
    public native int A(String in);
    static
    System.loadLibrary( "API2" );
    public static void main( String args[])
         Ex ex = new Ex();
         int r;
         r = ex.A("TEST");
    public Example()
    *****************Ex.java*****************
    public class exsysml
    public native int A(String in);
    public exsysml()
    System.loadLibrary("API3");
    The above way works. But I need only one .java file to load both the .DLL files. i.e.
    import java.io.*;
    import java.util.*;
    public class Example
    public native int A(String in);
    static
    System.loadLibrary( "API2" );
    System.loadLibrary( "API3" );     
    public static void main( String args[])
         Example ex = new Example();
         int r;
         r = ex.A("TEST");
    public Example()
    but when I do this way it doesn't work and I get a UnSatisfiedLinkage Error at ex.A("TEST"). While doing the top way it works.
    How can I fix this to just have one .java file and load both the library files as done in the bottom program but doing this program doesn't work. Any help is appreciated.
    Thanks!

    what I figured out so far is that we can only load one library file in a single class and define all the native methods present in that library in the class where we are loading it. Means we can't load multiple library files in a single class. It's just my thought else if someone provides a better solution. I may be wrong so that's why I need your help.
    Thanks

  • Is there anyone at all here who has successfully compiled and deployed an SSRS custom report item in VS2012?

    Is there anyone at all here who has successfully compiled and deployed an SSRS custom report item in VS2012?  Is there a demo out there that actually works in VS2012?  Is there anyone who has actually been able to compile and deploy that
    apparently obsolete Polygons demo?  (Pardon my impatience but I'm running a bit short of time here.)
    After much hacking and googling I was able to get Polygons to compile but I still can't deploy it to the toolbox.  ('The custom report item type PolygonsDesigner is not installed').   I've modified the RSReportDesigner.config
    as instructed but I have no rssrvpolicy.config file on my local machine and
    as yet I have no idea if that is necessary for local development.
    In order to get it to compile I first added the reference  C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.ReportingServices.ProcessingCore.dll to both projects.
    To the PolygonsDesigner Project I also added the references:
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.ReportDesigner.Controls.dll
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.ReportingServices.Designer.11.0.dll
    C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\Microsoft.ReportingServices.Interfaces.dll
    Are these the correct references?  
    Exactly what software do you need installed on your local machine in addition to VS2012 in order to create a custom control?
    (Designer.11.0 was added per the instructions in reference: https://connect.microsoft.com/VisualStudio/feedback/details/783391/unable-to-integrate-previously-working-ssrs-custom-report-item-to-vs-2012s-toolbox  
    After that I added the alias RSDesigner to it's properties and   extern alias RSDesigner; at the top of the PolygonsDesigner.cs file. )
    As of now, the top of the PolygonsDesigner.cs is as follows.  I don't recall making any other changes to the code.  As far as I can remember this is all I did in order to be able to compile the code in VS2012.
        extern alias RSDesigner;
        using System;
        using System.ComponentModel;
        using System.ComponentModel.Design;
        using System.Collections;
        using System.Collections.Generic;
        using System.Diagnostics;
        using System.Drawing;
        using System.Windows.Forms;
        using Microsoft.ReportDesigner;
        using Microsoft.ReportDesigner.Design;
        using Microsoft.ReportingServices.Interfaces;
        using Microsoft.ReportingServices.RdlObjectModel;
        using System.Xml;
        using System.Xml.Xsl;
        using System.Xml.XPath;
        [LocalizedName("Polygons")]
        [Editor(typeof(CustomEditor), typeof(ComponentEditor))]
        [ToolboxBitmap(typeof(PolygonsDesigner), "Polygons.ico")]      
        [CustomReportItem("Polygons")]
        [ToolboxItem(typeof(RSDesigner::Microsoft.ReportDesigner.Shell.CRIToolboxItem))] 
        [System.CLSCompliant(false)]
        public class PolygonsDesigner : CustomReportItemDesigner
        {   etc...

    Just fixed this myself.
    It appears the documentation online is wrong and the sample code is missing a reference to a reporting services dll and an attribute.
    What you need to do to get it working in VS2012 is add a reference to: Microsoft.ReportingServices.designer.11.0.dll to the PolygonsDesigner project and then add the following attribute to the PolygonsDesigner class: [ToolboxItem(typeof(Microsoft.ReportDesigner.Shell.CRIToolboxItem))]
    I also removed the [System.CLSCompliant(false)] attribute.
    You then recompile and place both dlls in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies directory and the PolygonsDesigner.dll into the C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin
    or what ever is you reporting services path.
    You also need to change the Microsoft example for the rereportserver.config file to:
        <ReportItemDesigner>
       <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsDesigner, PolygonsDesigner" />
        </ReportItemDesigner>
        <ReportItems>
       <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsCRI,PolygonsCRI"/>
        </ReportItems>
     Notice that I changed the namespaces and class to what is in the actual code so if you change it make sure you change it here.
    And here in the RSReportDesigner.config:
    <ReportItems>
          <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsCustomReportItem,PolygonsCRI" />
        </ReportItems>
        <ReportItemDesigner>
          <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsDesigner, PolygonsDesigner" />
        </ReportItemDesigner>
        <ReportItemConverter>
          <Converter Source="Chart" Target="Polygons" Type="PolygonsCRI.PolygonsConverter, PolygonsDesigner" />
        </ReportItemConverter>
    Notice I haven't changed the last part as I didn't know what the PolygonsCRI.PolygonsConverter was.
    And make sure the rssrvpolicy.config looks like this:
         <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Description="This code group grants PolygonsCRI.dll FullTrust permission. ">
           <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.SQLSERVER\Reporting Services\ReportServer\bin\PolygonsCRI.dll" />
        </CodeGroup>
    After a restart of ssrs and relaunch of VS2012 I opened a test project and added the PolygonsDesigner.dll to the toolbox and it works.
    Jamie

  • How to Compile and run Smart Card Application

    hi
    any one can help me reagrding Javacard API. i download the JavaCard Development Kit from sun and install on my machine but i didn't get all java files and class files of JavaCard API. where i obtain those files so my application get compile and run.
    pls help me i m new in this technology.
    Thanks in Advance.

    My program Test.java in F:\Tomcat5\webapps\Ambika\WEB-INF\Classes. I compiled in the format below. I got like this. What should I do for this? But yesterday I compiled like this only, It compiled and the folder com\cert\Test.class is created. Today again I compiled the pgm after deleting the already created folder 'com\cert', I got the error like this.
    I've given my pgm and the thing I've got when I compiled it.
    Test.java
    package com.cert;
    public class Test
         public void display()
              System.out.println("Hai");
    F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>javac -d F:\Tomcat5\webapps\Ambika\WEB-INF\Classes\Test.java
    javac: no source files
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are u
    sed
    -classpath <path> Specify where to find user class files
    -cp <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system
    F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>
    Plz help me.
    thanks in advance
    Ambika

  • How can I compile and run other java classes from within an application?

    Hello there everyone! I really hope that someone can help me. I am writing a program that must be able to compile and run other java classes that are in different files, much like development environments like Kawa or Forte allow you to do.
    There has to be a way of doing this ( I hope!! ), but i can't seem to find it!!
    I have tried using this command to compile:
    Runtime.getRuntime().exec ("c:\\programs\\javac className.java");
    ...and this one to run:
    Runtime.getRuntime().exec ("c:\\programs\\java className");
    ...but neither works!!! I can compile and run classes that are in the same file as my application, but I can't get it to work at all for files in different directories or files.
    PLEASE, PLEASE, PLEASE help me - i've run out of ideas, and i need this to be working in 3 days!!!
    Thank you very much for any help anyone can give me, I really appreciate it!! Thanks again!!
    Adrian ( ...in distress!! )

    public class JavaCompiler{
       public static void main(String[] args)throws Exception{ //sorry bout the laziness
          if(args == null || args.length != 1){
             System.out.println("Usage: java JavaCompiler MyClass.java");
             System.exit(0);
          String className = args[0];
          Runtime rt = Runtime.getRuntime();
          Process p = rt.exec("javac " + className); //consider setting cpath for this
          p.waitFor();
          //now try to run after it is done.
          p = rt.exec("java " + className.substring(0, (className.length() - ".java".length()));
          p.waitFor();
          //do some other stuff
    }This should get you going. You may consider looking into the System.getProperty() method in order to determine the type of OS it is running on in order to findo out what command to run. I know that the sun tool listed above is nice, but by my understanding the sun tools provided are not guaranteed to stay the same. I'm no expert on this matter, but that is one of the reasons there is no API documentation for those tools. Also, I don't believe those tools come packaged with the JRE. (Of course if you are making an IDE it will be expected that the user has an sdk installed. Good luck with figuring this thing out.

  • System.LoadLibrary + dlopen -- callback causes unresolved symbol

    Hi guys,
    I am currently trying to use the API
    System.loadLibrary(String name)in order to dynamically link shared libaries to SOLARIS JVM.
    I am facing some unresolved symbol at run-time .
    I load a shared library libhello1 (using system.LoadLibary)
    and I call from this lib (via JNI interface) a method which
    loads a second library libhello2(using dlopen) and invokes hello2().
    hello2 will call back a method hello_bug which is implemented in libhello1.
    There is the a mutual or cyclic dependence. This dependance is correctly handled if I link the libhello1 to a standard C implemented executable.
    But if I load libHello1 via System.Load, the second lib is correctly loaded but the call back is not possible due to unresolved symbol.
    It seems like the symbols are not kept in this case(or the dlopen creates a different thread?...)
    The workaround to fix the issue is to link explicitely libHello1 to libHello2 when building libHello2.
    I don't know if this is clear to everyone so
    I have reproduced this on a very simple case.
    Basicaly, I have implemented in standard C language 2 shared libraries:
    libHelloModule1.so, libHelloModule2.so
    one standard executable and one java interface to call the method
    Below is the full code for reproduce:
    hello1.h:
    #include <dlfcn.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <iostream>
    #include <jni.h>
    #include "hello_jni.h" [u]//automatically generated by javah -- ref Makefile[/u]
    extern "C"  void hello_bug();
    hello1.cc :#include "hello1.h"
    extern "C" {
    JNIEXPORT void JNICALL Java_com_helloworld_Hello_ShowMessage
      (JNIEnv *, jobject, jstring){
    void *handle;
    const  char *error;
    void  (*init) (void);
    printf(" load Hello2 \n");
    handle = dlopen ("libHelloModule2.so", RTLD_LAZY);
    printf (" lib Hello2 onload.. \n");
    error = dlerror();
    if (!handle) {
          printf ("lib HelloModule2 not loaded correctly %s \n", error);
          exit(1);
       dlerror();
       init =(void(*)())  dlsym(handle, "hello2");
      error = dlerror();
            if(error)
                    fprintf(stderr, "Could not find print_hello(): %s\n",
    error);
                    exit(1);
    (*init)();
        dlclose(handle);
    void hello_bug()
    printf ("Hello bug correctly  invoked : CQFD\n");
    }// extern "C"
    hello2.cc
    #include "hello1.h"
    typedef void  ( *PF1) (char *, char *);
    extern "C" {
    void hello2(){
    printf ("Hello2 : ping Hello1\n");
    /*simple call work in c not via JNI*/
    hello_bug();
    Hello.java :
    package com.helloworld;
    import java.util.*;
    import java.io.*;
    public class Hello  {
      private native void ShowMessage(String msg);
      public void initialized() {
                System.out.println(" ShowMessage - called");
      try {
              ShowMessage("Generated with JNI");
           } catch (Exception e ) {
                e.printStackTrace();         }
      public Hello(){
      System.loadLibrary("HelloModule1");
                System.out.println(" HelloModule1 loaded");
    TestLocal.java :
    import java.util.*;
    import java.io.*;
    import com.helloworld.Hello;
    public class TestLocal{
    public TestLocal(){
            System.out.println("test local");
    public static void main(String[] args) {
            TestLocal test_local = new TestLocal();
            Hello test = new Hello();
            test.initialized();
    }THE MOST IMPORTANT IS IN THE MAKEFILE:
    Makefile :all: Hello.jar hello_jni.h libHelloModule1.so libHelloModule2.so TestLocal.class dummy
    Hello.jar: com/helloworld/Hello.class
    jar cvf $@  com/helloworld
    com/helloworld/Hello.class: Hello.java
    $(JAVAC)  -d . Hello.java
    hello_jni.h: Hello.jar
    $(JAVAH) -jni -o $@ -classpath ./Hello.jar com.helloworld.Hello
    libHelloModule1.so : hello_jni.h hello1.o  
    gcc  -G  -o $@ hello1.o -lstdc++
    libHelloModule2.so : hello2.o
    gcc   -G  -o $@ hello2.o -Wl -lstdc++  -L. -lHelloModule1   [u] # -->CASE  1 :THIS WORKS [/u]
    gcc   -G  -o $@ hello2.o -Wl -lstdc++ [u] #-->CASE 2 :THIS  DOES NOT WORK[/u]
    dummy : dummy_main.o
    gcc  -o $@ dummy_main.o -L. -lHelloModule1 -L/usr/local/lib -lstdc++
    hello2.o : hello2.cc
    gcc -I. -O -c  hello2.cc
    hello1.o : hello1.cc
    gcc -I. -O -c  hello1.cc
    TestLocal.class : TestLocal.java
    $(JAVAC) -classpath  . -d . TestLocal.java
    dummy_main.o :  dummy_main.cc
    gcc -I. -O -c  dummy_main.cc
    clean:
    rm -rf com *.o *.so *.class *.jar hello_jni.h dummyCASE 1 : libHelloModule1.so is explicitely linked to libHelloModule2
    myhost % dummy
    load Hello2
    lib Hello2 onload..
    Hello2 : ping Hello1
    Hello bug correctly invoked : CQFD
    myhost % java -cp . TestLocal
    test local
    HelloModule1 loaded
    ShowMessage - called
    load Hello2
    lib Hello2 onload..
    Hello2 : ping Hello1
    Hello bug correctly invoked : CQFD
    CASE 2 : libHelloModule1.so is not explicitely linked to libHelloModule2
    myhost % dummy
    load Hello2
    lib Hello2 onload..
    Hello2 : ping Hello1
    Hello bug correctly invoked : CQFD
    myhost % java -cp . TestLocal
    test local
    HelloModule1 loaded
    ShowMessage - called
    load Hello2
    lib Hello2 onload..
    lib HelloModule2 not loaded correctly ld.so.1: java: fatal: relocation error: file ./libHelloModule2.so: symbol hello_bug: referenced symbol not found
    My concern is to have this working in CASE1 with the JNI interface the same way it does in standard C built runtime.
    So does any have encountered this?
    Is there something I missed somewhere?
    Thanks lot for your help
    Youss

    Hi,
    I have implemented JNative which seems to be close to your problem.
    It works under Windows and Linux, and loads libraries via dlopen and dlsym.
    You can have a look at it's implementation at http://jnative.cvs.sourceforge.net/jnative/JNativeCpp/
    Don't forget to load your libraries before trying to call them with System.load("/path/to/your/lib.so"); if they are not referenced by LD_LIBRARY_PATH.
    This post may be false since I know nothing about Solaris. Perhaps JNative may be ported under Solaris ?
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • System.loadLibrary works in 1.3.1 but not in 1.2.2

    I Have a basic hello world application on Sun Solaris 7 that calls C++ from Java using JNI.
    The code works well on 1.3.1, but when I recompile it under 1.2.2 and run I get the following exception when I call System.loadLibrary to load my shared library:
    java.lang.UnsatisfiedLinkError: no MyLib in java.library.path
    My LD_LIBRARY_PATH is set correctly since it worked under 1.3.1.
    Just in case, I used the following code to get and set the java.library.path to no avail.
    // Check System properties
    String strLibPath = System.getProperty("java.library.path");
    System.out.println("The Lib Path before set == " + strLibPath);
    StringBuffer strLibPathBuffer = new StringBuffer("/u/kbonacc/mypath:");
    strLibPathBuffer.append(strLibPath);
    System.setProperty("java.library.path", strLibPathBuffer.toString());
    strLibPath = System.getProperty("java.library.path");
    System.out.println("The Lib Path after set == " + strLibPath);
    Are there any differences between 1.3.1 and 1.2.2 in this respect?
    Thanks,
    -- Ken

    In the bug parade I've heard excuses from Sun programmers that this is a read-only property and isn't supposed to be changed. It probably took them longer to write the reply to the bug than it would have to fix the code.
    I looked at the source code for the ClassLoader and for the source release of the JDK 1.3.1 and here's the code I found in the ClassLoader.loadLibrary() method:
            if (sys_paths == null) {
                    usr_paths = initializePath("java.library.path");
                    sys_paths = initializePath("sun.boot.library.path");
            }It seems it parses and caches the system and user library paths on startup and then never bothers to check them to see if they've changed ever again. I think it would be pretty simple to rewrite that code block by moving one line of code down two lines as this:
            if (sys_paths == null) {
                    sys_paths = initializePath("sun.boot.library.path");
            usr_paths = initializePath("java.library.path");I mean, it's not as if loadLibrary is really performance intensive or even critical enough to bother caching at all!
    This one code change could fix a lot of headaches.
    The particular headache I'm working on is that there doesn't seem to be any support in the Servlet 2.2 or 2.3 specification for JNI files. I'd really love to be able to use a directory like WEB-INF\jni to store libraries that need to be distributed with my web application. I tried to dynamically change java.library.path to include WEB-INF\jni, but alas I ran into the same problem you did, it doesn't work.
    Is is possible for this to be fixed, ever? I think it would take longer to say no and make up a reason why not then it would to actually make the fix... seems a good enough arguement to do it to me.
    And alternately, can we come up with a standard place to put JNI stuff for web applications in the next Servlet standards?
    Thanks in advance!
    -J.C.
    [email protected]

  • How to Set up the  variables and others to compile and Run Java Programs

    Hello,
    I have just downloaded the jdk1.6.0_07 and jre1.6.0_07 and installed it in C:\Program files\Java in my Windows XP ,So please tell me how to sett up the enviroment variables etc to compile and run Java Programs from Command Prompt.
    thanks

    To set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:
    1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
    2. Click Advanced > Environment Variables.
    3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:
    C:\Program Files\Java\jdk1.6.0_<version>\bin

  • How to compile and execute a generated file

    Hi,
    Can somebody help me please? My program goes like this:
    I'm creating a program wherein there are two TextArea, left and right, and a button. The role of the left TextArea is where I will type a Java code (what i mean is a class). After typing, the next thing is to press the button. The role of the button, in a user side view, is to show the output of the written java code from the left TextArea to the right TextArea. To have an idea of the program I am creating please refer at this link, http://w3schools.com/html/tryit.asp?filename=tryhtml_tables. This is similar to what im doing.
    My idea is to transfer all what are written in the left TextArea in a file using FileOutputStream and name the file by default as "Testing.java". Definitely the user shall be forced to write a class named Testing.java in the left TextArea. My question is, how am I gonna compile the generated Testing.java, run it at once and post the output at the left TextArea?
    I hope somebody could help me regarding this matter. Below is my code I've done:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends Frame implements ActionListener
    private TextArea ta_code; //where the java code is written
    private TextArea ta_output; //where the output of the java code will be printed
    private Button btn_ExecComp; //compiles the program written in the ta_code. Execute's the generated class and print the result in the ta_output
    private Panel btn_panel;
    private Panel ta_output_panel;
    private Panel ta_code_panel;
    private Panel ta_panel;
    private Panel main_panel;
    private String str_code;
    private String str_output;
    public Test()
    initialize();
    setupObj();
    public void initialize()
    String text = "public class Testing \n";
    text = text + "{\n";
    text = text + " \n";
    text = text + "public static void main(String args[]) \n";
    text = text + "{ \n";
    text = text + " //insert your code here \n";
    text = text + "} \n";
    text = text + "\n";
    text = text + "} \n";
    ta_code = new TextArea(text);
    ta_output = new TextArea();
    btn_ExecComp = new Button("Execute Code");
    btn_panel = new Panel();
    ta_code_panel = new Panel();
    ta_output_panel = new Panel();
    ta_panel = new Panel();
    main_panel = new Panel();
    public void setupObj()
    btn_ExecComp.addActionListener(this);
    btn_panel.setLayout(new FlowLayout());
    ta_code_panel.setLayout(new FlowLayout());
    ta_output_panel.setLayout(new FlowLayout());
    ta_panel.setLayout(new FlowLayout());
    main_panel.setLayout(new FlowLayout());
    btn_panel.add(btn_ExecComp);
    ta_output_panel.add(ta_output);
    ta_code_panel.add(ta_code);
    ta_panel.add(ta_code_panel);
    ta_panel.add(ta_output_panel);
    main_panel.add(btn_panel);
    main_panel.add(ta_panel);
    this.add(main_panel);
    this.pack();
    this.setVisible(true);
    public void actionPerformed(ActionEvent ae)
    if(ae.getSource() == btn_ExecComp)
    str_code = ta_code.getText();
    try
    byte[] byte_code = str_code.getBytes();
    FileOutputStream fos = new FileOutputStream("Testing.java");
    fos.write(byte_code);
    System.out.println("Testing.java successfully written");
    * How am i be able to compile, run the generated class file and post the output at the right TextArea namely ta_output?
    System.out.println("compiling...");
    System.out.println("compiling successful");
    System.out.println("executing...");
    catch(Exception e)
    e.printStackTrace();
    public static void main(String a[])
    Test t = new Test();
    }

    Hi All,
    After reading Pro*C Question thread I have tried below steps to compile my .C program, but failed with the given errors
    $->cc -I$ORACLE_HOME/precomp/public -L$ORACLE_HOME/lib first.c -o sample
    ld: 0711-317 ERROR: Undefined symbol: .sqlcxt
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit statusAfter receiving above error I tried below command as an alternative
    $->cc -I$ORACLE_HOME/precomp/public -L$ORACLE_HOME/lib first.c -o first -lclntsh -lsql10
    collect2: library libsql10 not foundCould you please help in resolving above error? Whats missing exactly?

  • How to compile and run package programs in Java

    Hi,
    I want to know how to compile and run the package programs in Java using -d. instead of creating the package folder manually.
    eg:
    package Test;
    class test1
    public void disp()
    //Any code;
    I want to compile this without creating the folder ' Test ' manually. that is if we use -d with javac the Test folder will be created automatically. I need the format of -d
    could anyone please help me.
    Thanks in Advance ,
    Ambika

    My program Test.java in F:\Tomcat5\webapps\Ambika\WEB-INF\Classes. I compiled in the format below. I got like this. What should I do for this? But yesterday I compiled like this only, It compiled and the folder com\cert\Test.class is created. Today again I compiled the pgm after deleting the already created folder 'com\cert', I got the error like this.
    I've given my pgm and the thing I've got when I compiled it.
    Test.java
    package com.cert;
    public class Test
         public void display()
              System.out.println("Hai");
    F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>javac -d F:\Tomcat5\webapps\Ambika\WEB-INF\Classes\Test.java
    javac: no source files
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are u
    sed
    -classpath <path> Specify where to find user class files
    -cp <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system
    F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>
    Plz help me.
    thanks in advance
    Ambika

  • How to develope, compile  and run soap service

    we want to implement the soap sevice in our concern.So its very diffcult to develope the soap program.I dont know about the soap service.please give me a input about soap and how to develope soap programs.Pls also give some sample programs and how to compile and run those programs.In our concern we are using UNIX operating system.
    Thanking you
    Yours faithfully
    Saran

    You should start by posting questions regarding web services on the correct forum ;)
    Next go to xml.apache.org and read the documentation regarding Apache Axis.
    You could also take a look at the Spring Framework's support for web services.
    You could even take a look at the Sun Web Service tutorials.
    The above resources have plenty of examples and sample code.

Maybe you are looking for