Jni native print

Hi,
I've implemented a native paint method. The question is how can I print since getting a native device seems to be attached to the Canvas and not to the Graphics?
I've made my Canvas Printable and the method print is as follow:
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
     my_native_paint_method (this, g);
     return NO_SUCH_PAGE;
}but of course, the output goes to the screen and not to the printer.
Dom

Hi,
I've implemented a native paint method. The question is how can I print since getting a native device seems to be attached to the Canvas and not to the Graphics?
I've made my Canvas Printable and the method print is as follow:
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
     my_native_paint_method (this, g);
     return NO_SUCH_PAGE;
}but of course, the output goes to the screen and not to the printer.
Dom

Similar Messages

  • Access object attributes using other object JNI native method

    Hi. I'm trying to change an attribute of object O1 from another object O2 without invoking a O1 method and without making the attribute as public or protected.
    The only possibility that comes to my mind for doing so is writting a JNI native method
    public class O1 {
    static public native changeAttribute (Object O2, Object newAttributeValue) ;
    that change the attribute memory reference, but all I've found about accesing attributes in JNI is about accessing the invoker attributes (in this case, O1).
    �Does any one know if it's possible to do so? Thanks.

    I know that is not a good practice but I cannot figure out another way.
    I'll try to explain the whole problem so you see the reason. I'm working with transactions, using objects as the data. An object can be opened for write by several transactions because the granularity for conflicts is not the object, is each of its attributes. As long as two transaction don't write the same attribute, they both can write. For writing, each transactions uses a private copy of the object. At committing, the actual copy of the object must be replaced by the committer one, but as far as the granularity is the object attributes, only each written attribute must be replaced (if not, only the last commit would be visible).
    This attribute replace must be done by the transaction manager as far as the transactional object is provided by the client. So what i was thinking was to use JNI or some trick like that to replace the object attributes transparently to the object.
    I hope the explain is clear, my english is a little asleep :-(.
    How to do it with reflection? I thought that was only for method calling. Anyway, there wouldn't be problems if the attributes are private?
    Thanks for answering.
    EDIT: I've been able to change a public field using reflection, but not the private one
    import java.lang.reflect.*;
    class Caca {
    public static void main(String[] args) {
    Integer r = new Integer(0);
    System.out.println("original: " + r.toString());
    modifyWidth(r, 300);
    System.out.println("modified: " + r.toString());
    static void modifyWidth(Integer r, int newValue ) {
    Field valueField; Class c = r.getClass();
    try {
    valueField = c.getField("value");
    valueField.set(r, newValue);
    } catch (Exception e) { System.out.println(e); }
    Message was edited by:
    dfasdfsdafsadfasdf

  • JVM dies when JNI native code causes a SIGABRT from assertions

    Hi,
    I am wondering whether there is a way to prevent the JVM from dying when the JNI native code hits an assertion.
    #include "NativeTest.h"
    #include <assert.h>
    JNIEXPORT jstring JNICALL Java_NativeTest_sayHello (JNIEnv *env, jobject thisobject, jstring js)
    assert(0);
    return js;
    Calling this code from Java through JNI causes a SIGABRT when assert(0) is hit. This causes the java program to terminate. Is there a way for the JVM to recover from the SIGABRT from the native code?

    929919 wrote:
    I am wondering whether there is a way to prevent the JVM from dying when the JNI native code hits an assertion.There is no way to prevent the VM from exiting if native code does anything that causes an exit.
    An assertion is only one way that can happen.
    So to prevent the VM from exiting - don't run native code. The safe way to execute OS native library is to do the following.
    1. Wrap the library in an executable.
    2. Create a communications API for the executable.
    3. Manage the executable via Java Runtime.exec/ProcessBuilder.
    4. Talk to the executable using the communications API from 2 in the java code.
    The above is safe because if the library exits it exits the executable, not the VM.

  • Native print dialog box

    I want to show a native print dialog box when the user clicks on my printButton.
    I have the following code for this:
    private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
            try
                PrinterJob job = PrinterJob.getPrinterJob();
                job.setPrintable(this);
                if (job.printDialog())
                    job.print();
            catch (PrinterException e)
               JOptionPane.showMessageDialog(this, e);
        }    I have also a page setup button:
    private void setupButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
            PrinterJob job = PrinterJob.getPrinterJob();
            //selectedFormat is a member variable
            selectedFormat = job.pageDialog(selectedFormat);
        }  The problem is the changes I have made in "setup" doesnt take effect in printing...
    How can I solve this? (with native dialog box) Thanks

    You are right, I�ve just proved it with job as a member variable and it works in a perfect way, thanks ;).
    I have another question related to this solution, by the fact to declare job as member variable :
    PrinterJob job=PrinterJob.getPrinterJob();Are a lot of resources being wasted?
    Thanks ;)

  • Error in Java Runtime Environment when running JNI native library

    Hi,
    I am kinda new to JNI but understand it [and done some tutorials]. I am trying to implement JavaStyle [ a Java vst host that uses JNI ] and have reached a point where i successfully build the native code to a dll, and almost manage to load the native dll library. I do not get a Unsatisfied Link Error, but instead have the JVM close due an internal error.
    I am completely lost and dont know what to try now, and I would appreciate any help offered.
    I have debugged and the error arrives at the System.load line of code:
      static {
        System.out.print("Pre loadLibrary..."); 
        System.loadLibrary("JaVaSTyle");
        System.out.println("JavaStyle dll loaded in JVSTLibrary");
      }Detail: I compiled the native library with MS visual studio .NET 2003 using the project settings supplied from the CVS repository.
    I use Netbeans 6.0 for the java side of things. The console output is:
    # An unexpected error has been detected by Java Runtime Environment:
    #  Internal Error (0xe0434f4d), pid=1500, tid=6012
    # Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
    # Problematic frame:
    # C  [kernel32.dll+0x12a5b]
    # An error report file with more information is saved as hs_err_pid1500.logand the error report is :
    # An unexpected error has been detected by Java Runtime Environment:
    #  Internal Error (0xe0434f4d), pid=1500, tid=6012
    # Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
    # Problematic frame:
    # C  [kernel32.dll+0x12a5b]
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    ---------------  T H R E A D  ---------------
    Current thread (0x00297000):  JavaThread "main" [_thread_in_native, id=6012]
    siginfo: ExceptionCode=0xe0434f4d
    Registers:
    EAX=0x0090f4c0, EBX=0x00000001, ECX=0x000b0fd0, EDX=0x00000000
    ESP=0x0090f4bc, EBP=0x0090f510, ESI=0x00000000, EDI=0x00000000
    EIP=0x7c812a5b, EFLAGS=0x00000246
    Top of Stack: (sp=0x0090f4bc)
    0x0090f4bc:   000b0fd0 e0434f4d 00000001 00000000
    0x0090f4cc:   7c812a5b 00000000 791b9d02 02ea1198
    0x0090f4dc:   07624998 000b0fd0 0090f4fc 791be271
    0x0090f4ec:   000ae008 00000002 07624998 00000000
    0x0090f4fc:   0090f50c 791be286 000ae008 07624998
    0x0090f50c:   0090f51c 0090f568 7921020d e0434f4d
    0x0090f51c:   00000001 00000000 00000000 000b0fd0
    0x0090f52c:   0090f578 00000001 7c812a5b 0090f1f0
    Instructions: (pc=0x7c812a5b)
    0x7c812a4b:   8d 7d c4 f3 a5 5f 8d 45 b0 50 ff 15 08 15 80 7c
    0x7c812a5b:   5e c9 c2 10 00 85 ff 0f 8e 36 93 ff ff 8b 55 fc
    Stack: [0x008c0000,0x00910000),  sp=0x0090f4bc,  free space=317k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C  [kernel32.dll+0x12a5b]
    C  [mscorwks.dll+0x6020d]
    C  [mscorwks.dll+0x60190]
    C  [mscorwks.dll+0x60144]
    C  [mscorwks.dll+0xa6dcb]
    C  [mscorwks.dll+0x26a7e]
    C  0x000b15f6
    j  java.lang.ClassLoader$NativeLibrary.load(Ljava/lang/String;)V+0
    j  java.lang.ClassLoader.loadLibrary0(Ljava/lang/Class;Ljava/io/File;)Z+300
    j  java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)V+268
    j  java.lang.Runtime.loadLibrary0(Ljava/lang/Class;Ljava/lang/String;)V+54
    j  java.lang.System.loadLibrary(Ljava/lang/String;)V+7
    j  org.tango.JaVaSTyle.JVSTLibrary.<clinit>()V+10
    v  ~StubRoutines::call_stub
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j  java.lang.ClassLoader$NativeLibrary.load(Ljava/lang/String;)V+0
    j  java.lang.ClassLoader.loadLibrary0(Ljava/lang/Class;Ljava/io/File;)Z+300
    j  java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)V+268
    j  java.lang.Runtime.loadLibrary0(Ljava/lang/Class;Ljava/lang/String;)V+54
    j  java.lang.System.loadLibrary(Ljava/lang/String;)V+7
    j  org.tango.JaVaSTyle.JVSTLibrary.<clinit>()V+10
    v  ~StubRoutines::call_stub
    j  org.tango.JaVaSTyle.Main.main([Ljava/lang/String;)V+3
    v  ~StubRoutines::call_stub
    ---------------  P R O C E S S  ---------------
    Java Threads: ( => current thread )
      0x02a6d800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4752]
      0x02a68c00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4472]
      0x02a67800 JavaThread "Attach Listener" daemon [_thread_blocked, id=2016]
      0x02a66c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4328]
      0x02a62400 JavaThread "Finalizer" daemon [_thread_blocked, id=5072]
      0x02a5dc00 JavaThread "Reference Handler" daemon [_thread_blocked, id=5552]
    =>0x00297000 JavaThread "main" [_thread_in_native, id=6012]
    Other Threads:
      0x02a5cc00 VMThread [id=4660]
      0x02a6f000 WatcherThread [id=3864]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation   total 960K, used 199K [0x22970000, 0x22a70000, 0x22e50000)
      eden space 896K,  22% used [0x22970000, 0x229a1ff0, 0x22a50000)
      from space 64K,   0% used [0x22a50000, 0x22a50000, 0x22a60000)
      to   space 64K,   0% used [0x22a60000, 0x22a60000, 0x22a70000)
    tenured generation   total 4096K, used 0K [0x22e50000, 0x23250000, 0x26970000)
       the space 4096K,   0% used [0x22e50000, 0x22e50000, 0x22e50200, 0x23250000)
    compacting perm gen  total 12288K, used 23K [0x26970000, 0x27570000, 0x2a970000)
       the space 12288K,   0% used [0x26970000, 0x26975c48, 0x26975e00, 0x27570000)
        ro space 8192K,  66% used [0x2a970000, 0x2aebf860, 0x2aebfa00, 0x2b170000)
        rw space 12288K,  52% used [0x2b170000, 0x2b7bf078, 0x2b7bf200, 0x2bd70000)
    Dynamic libraries:
    0x00400000 - 0x00423000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\java.exe
    0x7c900000 - 0x7c9b0000      C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c8f5000      C:\WINDOWS\system32\kernel32.dll
    0x77dd0000 - 0x77e6b000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77e70000 - 0x77f02000      C:\WINDOWS\system32\RPCRT4.dll
    0x77fe0000 - 0x77ff1000      C:\WINDOWS\system32\Secur32.dll
    0x7c340000 - 0x7c396000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\msvcr71.dll
    0x6d870000 - 0x6daba000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\client\jvm.dll
    0x7e410000 - 0x7e4a0000      C:\WINDOWS\system32\USER32.dll
    0x77f10000 - 0x77f57000      C:\WINDOWS\system32\GDI32.dll
    0x76b40000 - 0x76b6d000      C:\WINDOWS\system32\WINMM.dll
    0x76390000 - 0x763ad000      C:\WINDOWS\system32\IMM32.DLL
    0x5cd70000 - 0x5cd77000      C:\WINDOWS\system32\serwvdrv.dll
    0x5b0a0000 - 0x5b0a7000      C:\WINDOWS\system32\umdmxfrm.dll
    0x003a0000 - 0x003ad000      C:\WINDOWS\system32\myokent.dll
    0x6d3c0000 - 0x6d3c8000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\hpi.dll
    0x76bf0000 - 0x76bfb000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d820000 - 0x6d82c000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\verify.dll
    0x6d460000 - 0x6d47f000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\java.dll
    0x6d860000 - 0x6d86f000      C:\Program Files\Java\jdk1.6.0_03\jre\bin\zip.dll
    0x10000000 - 0x10018000      D:\NetbeansWorkspace\myJavaStyle\JaVaSTyle.dll
    0x79170000 - 0x79196000      C:\WINDOWS\system32\mscoree.dll
    0x10480000 - 0x1053c000      C:\WINDOWS\system32\MSVCP71D.dll
    0x10200000 - 0x10287000      C:\WINDOWS\system32\MSVCR71D.dll
    0x77f60000 - 0x77fd6000      C:\WINDOWS\system32\SHLWAPI.dll
    0x77c10000 - 0x77c68000      C:\WINDOWS\system32\msvcrt.dll
    0x791b0000 - 0x79412000      C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll
    0x79040000 - 0x79085000      C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll
    0x7c9c0000 - 0x7d1d6000      C:\WINDOWS\system32\SHELL32.dll
    0x773d0000 - 0x774d3000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll
    0x5d090000 - 0x5d12a000      C:\WINDOWS\system32\comctl32.dll
    0x79780000 - 0x79980000      c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll
    0x774e0000 - 0x7761d000      C:\WINDOWS\system32\ole32.dll
    0x79430000 - 0x7947c000      C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\MSCORJIT.DLL
    0x51a70000 - 0x51af0000      C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\diasymreader.dll
    VM Arguments:
    java_command: org.tango.JaVaSTyle.Main
    Launcher Type: SUN_STANDARD
    Environment Variables:
    CLASSPATH=.;C:\jdk1.5.0_09\bin;C:\Program Files\Java\jre1.6.0_03\lib\ext\QTJava.zip
    PATH=C:\Program Files\MiKTeX 2.7\miktex\bin;c:\program files\imagemagick-6.3.7-q16;C:\texmf\miktex\bin;C:\Program Files\ActiveState Komodo IDE 4.2\;C:\Program Files\Autodesk\Maya2008\bin;C:\Python25\;C:\Program Files\PC Connectivity Solution\;C:\ORANT\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\GPS Pathfinder Office 3.00;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;C:\Program Files\Common Files\Motorola\Toolbox;C:\PROGRA~1\COMMON~1\Motorola\Toolbox;C:\Program Files\Novell\ZENworks\;C:\Program Files\Novell\SecureLogin;C:\Program Files\Smart Projects\IsoBuster;C:\Latex\MikTeX\V2.10;C:\PROGRA~1\CA\Common\SCANEN~1;C:\Program Files\CA\Common\ScanEngine;C:\Program Files\CA\SharedComponents\CAUpdate\;C:\Program Files\CA\SharedComponents\ThirdParty\;C:\Program Files\CA\SharedComponents\SubscriptionLicense\;C:\PROGRA~1\CA\ETRUST~1;C:\Program Files\QuickTime\QTSystem\;C:\cygwin\bin;C:\Program Files\Tcl\bin;D:\netbeansWorkspace\myJavaStyle;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Program Files\Csound\bin;C:\Program Files\CVSNT\
    USERNAME=hectorj
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 8, GenuineIntel
    ---------------  S Y S T E M  ---------------
    OS: Windows XP Build 2600 Service Pack 2
    CPU:total 1 (1 cores per cpu, 1 threads per core) family 6 model 13 stepping 8, cmov, cx8, fxsr, mmx, sse, sse2
    Memory: 4k page, physical 1047920k(270244k free), swap 2520456k(1654520k free)
    vm_info: Java HotSpot(TM) Client VM (1.6.0_03-b05) for windows-x86, built on Sep 24 2007 22:24:33 by "java_re" with unknown MS VC++:1310

    Something is wrong with the library.
    Staring at java code will not help you figure that out.
    Maybe it isn't intended to be loaded in java but instead it loads java itself?
    If not then write a C/C++ basic app that links that dll in and see if you can at least get it to start.

  • JNI -- Native String Conversion

    I have a question about this tutorial
    http://java.sun.com/docs/books/tutorial/native1.1/implementing/string.html
    which is on accessing Java Strings in native methods.
    In particular, the tutorial states:
    "Your native method needs to call GetStringUTFChars to correctly print the string passed to it from a Java application. GetStringUTFChars converts the built-in Unicode representation of a Java string into a UTF-8 string. "
    and also notes then when converting from a java String to a C string:
    "If the original string contained non-ASCII characters, some library functions may not behave as expected if passed the converted, UTF-8 string. For example, the result of passing such a UTF-8 string to the strlen function will not be the number of Unicode characters in the string."
    I am programming in C++, not C. I handle most of my string manipulations using the STL std::string class. Do I still need to worry about the unexpected behaviour mentioned in the paragraph above?
    Also, what is the relevant difference here between UTF and Unicode? Which does std::string work with?
    Thanks for any info,
    John

    Do I still need to worry ...1) yes; but if you have a C++ compiler that implements std::basic_string<wchar_t> (as known as wstring in Microsoft Visual C++), you can work with pure Unicode.
    Which does std::string work with...2) std::string is a typedef for std::basic_string<char>, and char is not UTF-8 neither Unicode: it's a signed 8-bit quantity that maps exactly to the byte type in Java.
    std::string can be used with UTF-8 (actually, the modified UTF-8 version that is used by Java).
    The only problem with std::string is if you have characters in Java that are represented as several bytes in UTF-8, std::string.size() (or std::string.length()) will report you the number of bytes in the UTF-8 representation of your string, not the length of your Java string in characters.
    To get the length of the Java string that you've stored in a std::string in characters, you'll need to use some C library function that understands UTF-8 encoding, or simply ask the JNI functions.

  • Native printing support in Pages for iPad

    Shopping for a printer that is natively supported in Pages. Any recommendations?

    Apologies ladies and gentlemen, found answer in iWork for iOS...

  • JNI native threads causing JRE to fail to shut down?

    Hello,
    I am using JNI to communicate with a COM object. I am reasonably certain at this point that my JNI code is handling this properly and the third party COM library is releasing the object in question. We allocate and release hundreds of these objects and we aren't observing any memory leaks. Likewise in our handling of events we receive from the COM object. We attach the thread to Java, deliver the event, and then detach the thread from Java, with very careful error handling around the event delivery to ensure that whatever else happens the detach gets called. This code is very robust and stable in operation and has been working at load in the field for over a year now without any customer problems in the JNI area.
    However, since day one, when I go to shut down the application, the JNI isn't winding down properly. As it happens, since the JRE is running a Tomcat, driven by a wrapper service, the wrapper eventually gives up waiting and shoots the JRE in the head, but the user experience of stopping the wrapper service is ugly and we'd like to clean that up. The JNI code, of course, runs as shared code in the Tomcat.
    It is possible that the third-party library, which does network communications, is keeping a thread pool for use with any of the COM objects even after all COM objects are released. This would be experienced as a one-time hit when the first object is allocated and not as a continual leak, so we'd be unlikely to notice it otherwise.
    Will native non-Java threads running in the JRE but not allocated by the JRE itself cause the JRE to hang on until they've spontaneously decided to clean themselves up? Threads that have never been attached to the JVM? How about threads that were briefly attached to the JVM but then detached? Any worse?
    Ralph

    Hi Ralph,
    I will need some more information regarding this issue.
    1. What platform are you on?
    2. Which JRockit version are you running?
    3. If you remove the wrapper service, does JRockit freeze without exiting properly?
    As a general recommendation I would try to upgrade to the latest JRockit version. It can be downloaded from the OTN http://www.oracle.com/technology/software/products/jrockit/index.html
    You may also try some verbose printouts to debug the issue a little further. Try
    -Xverbose:thread=debug,jni=debug
    This might give us some more insight in what is going on.
    Also when JRockit freezes you can output a Java stack trace using our 'jrcmd' tool which you can find in the same folder as the java executable. Run this tool without any parameters and it will output identifiers (numbers) for every running JRockit instance on your machine. Run the same tool again, this time append the identifier you believe is the one running the Tomcat and add the command 'print_threads', ie
    jrcmd <some_id_here> print_threads
    This may show what JRockit is waiting for.
    Cheers,
    /Henrik

  • How to root out memory leak with  Java JNI & Native BDB 11g ?

    We are testing a web application using the 32-bit compiled native 11g version of BDB (with replication) under 32-bit IBM 1.5 JVM via JNI under 64-bit RedHat Linux. We are experiencing what appears to be a memory leak without a commensurate increase in Java heap size. Basically the process size continues to grow until the max 32-process size is reached (4Gb) and eventually stops running (no core). Java heap is set to 2Gb min/max. GCs are nominal, so the leak appears to be native and outside Java bytecode.
    We need to determine whether there is a memory leak in BDB, or the IBM JVM or simply a mis-use of BDB in the Java code. What tools/instrumentation/db statistic should be used to help get to root cause? Do you recommend using System Tap (with some particular text command script)? What DB stats should we capture to get to the bottom of this memory leak? What troubleshooting steps can you recommend?
    Thanks ahead of time.
    JE.
    Edited by: 787930 on Aug 12, 2010 5:42 PM

    That's troublesome... DB itself doesn't have stats that track VM in any useful way. I am not familiar with SystemTap but a quick look at it seems to imply that it's better for kernel monitoring than user space. It's pretty hard to get DB to leak significant amounts of memory. The reason is that it mostly uses shared memory carved from the environment. Also if you are neglecting to close or delete some object DB generally complains about it somewhere.
    I don't see how pmap would help if it's a heap leak but maybe I'm missing something.
    One way to rule DB out is to replace its internal memory allocation functions with your own that are instrumented to track how much VM has been allocated (and freed). This is very easy to do using the interfaces:
    db_env_set_func_malloc()
    db_env_set_func_free()
    These are global to your process and your functions will be used where DB would otherwise call malloc() and free(). How you get usage information out of the system is an exercise left to the reader :-) If it turns out DB is the culprit then there is more thinking to do to isolate the problem.
    Other ideas that can provide information if not actual smoking guns:
    -- accelerate reproduction of the problem by allocating nearly all of the VM to the JVM and the DB cache (or otherwise limit the allowable VM in your process)
    -- change the VM allocated to the JVM in various ways
    Regards,
    George

  • Native printer driver (Mac)

    I have a mac laptop which uses a Xerox driver with department accounting which pops up a prompt asking for a department number every time a job is printed.  This driver works perfectly in any other program, but when I print with adobe reader, it doesn't display the prompt and tried to print with no department ID, which fails when it gets to the printer since this is required.  From what I can tell acrobat tries to override most of the print driver settings itself, which is most likely what's causing this.  I even tried the "Print as Image" option, but had the same problem.  Is there any way to get Acrobat to completly use the native OS printer driver instead of its custom one which doesn't seem to support the Xerox accounting feature?
    Thanks.
    Darren

    Hi,
    you can try to exchange your "pstops" file by the one from 10.5.4 as described in:
    http://discussions.apple.com/thread.jspa?threadID=1715794&tstart=0#8157481
    At least this fixed a similar problem in my case which appeared with 10.5.5 (or the latest HP printer driver update - I am not sure, because I installed both updates at quite the same time).
    Best regards,
    Steffen

  • JNI native method

    Say I create a JVM from native code and use it to popup a GUI... kinda like the next 2 lines:
    res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
    mid = (*env)->GetMethodID(env, cls, "showWindow", "()V"); // This MID will pop up gui
    Now, how do I make a button int he Java GUI call back down to the native code (C). Is this even possible without creating a shared library and doing System.loadLibrary() ?

    See JNI function RegisterNatives. This lets you put native methods in your main executable rather than needing a shared library.
    -slj-

  • JNI native drawing - Double Buffering issue

    Hi,
    I use JNI to paint from a C++ DLL onto a canvas, which works fine.
    The problem is that double buffering is not working though.
    In C++ I create an offscreen HDC, draw something on it and finally i bitblit the offscreen HDC to the parent window HDC.
    That is how double buffering is supposed to work. But each time i repaint my Canvas in Java, i see flickering:
    the background color is displayed first, then the C++ paintings are drawn.
    Since i already do double buffering in my C++ drawings, i don't know why there still is flickering.
    Should i do double buffering on my canvas also?
    How would this work, since my paint method looks like;
         private native void drawChart(Graphics g);
         public void paint(Graphics g)
              drawChart(g);
         }

    this is my lucky day :)
    the following thread on http://forum.java.sun.com/thread.jspa?threadID=562392&messageID=2767046 suggested to override the update method on the canvas, which works.
         // overridden to eliminate flicker
        public void update(Graphics g)
            paint(g);
        }

  • Native print dialog

    Hey everyone,
    I'm propably not the first one asking this question, but a google/forum sweep hasn't revealed a convincing answer to me.
    I'm having problems with during Java printing with the native settings not being obeyed by the print job I execute.
    My actual goal is to display the native dialog to the user, let the user alter whatever settings needed, and then extract these settings from the PrintService/PrinterJob.
    But AFAICS the native settings manipulated are completely ignored (or at least not accessible programmatically) - before going into further details I just want to know if it at all is possible, from Java (1.4.2 and later) to use the settings specified through this native dialog (which actually belongs to the "old" printing API) ?
    Any help appriciated,
    /Mikael

    You are right, I�ve just proved it with job as a member variable and it works in a perfect way, thanks ;).
    I have another question related to this solution, by the fact to declare job as member variable :
    PrinterJob job=PrinterJob.getPrinterJob();Are a lot of resources being wasted?
    Thanks ;)

  • JNI native thread priority

    Hi,
    I have some JNI code that spawns a win32 thread using CreateThread and then sets it priority using SetThreadPriority.
    If i set priority higher than ABOVE_NORMAL ( i would prefer time critical), it seems the JVM crashes on exit.
    I've commented everything out in the thread method itself except to let it do a while(true){Sleep(1);}.
    If i remove the SetThreadPriority or set it to ABOVE_NORMAL or less the JVM doesnt crash when the java code calls System.exit but otherwise it does.
    Any ideas concerning this?

    Hmm..
    I was using System.runFinalizersOnExit(true), when i removed that from the java side the problem disappeared. I dont really need to make that call anyway, but i dont like when errors disappears and i dont understand why, so i would like to know how that call in conjunction with a high priority native thread can cause a jvm crash?

  • Common JNI Native Library inside servlets

    I need to load a native library from a jee application, every things runs pretty well until I instanciate a new class inside a different application and try to load the same native library, wls throws a UnsatisfiedLinkException.
              How can I share the native library for both applications and avoid the UnsatisfiedLinkException?
              Any idea, thoughts?
              thanks

    Finally I get it working by myself. In difference to WAS, WLS does not have any document where specifies how to load a shared native library.
              After two weeks of research, I went for an EJB solution followed by a singleton class. Why EJB? because I need to have an only one object where I can load the native library both loaded by the same classloader and share it by any mean. With this implementation avoid the UnsatisfiedLinkException, and publish an object which has access to the native library. And finally the singleton, you know how it works, it loads once the native library in its constructor avoids the restriction to load just once a native library in the same JVM.

Maybe you are looking for