0

I do have got a button in my app to create snapshot from 3D scene. However, if my app runs from Japanese path, e.g. F:\テスト\myApp\bin, and system locale is set to Japan, clipboard is not created. While calling java.awt.datatransfer.Clipboard.setContents, I have got:

Exception in thread "main-FPSAWTAnimator-Timer0" java.lang.UnsatisfiedLinkError: 
F:\テスト\myApp\bin\jre\bin\jpeg.dll: Can't find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(JPEGImageWriter.java:180)
        at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(JPEGImageWriter.java:178)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.imageio.plugins.jpeg.JPEGImageWriter.<clinit>(JPEGImageWriter.java:177)
        at com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi.createWriterInstance(JPEGImageWriterSpi.java:96)
        at javax.imageio.spi.ImageWriterSpi.createWriterInstance(ImageWriterSpi.java:351)
        at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:843)
        at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:827)
        at sun.awt.datatransfer.DataTransferer.imageToStandardBytesImpl(DataTransferer.java:2203)
        at sun.awt.datatransfer.DataTransferer.imageToStandardBytes(DataTransferer.java:2145)
        at sun.awt.windows.WDataTransferer.imageToPlatformBytes(WDataTransferer.java:352)
        at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1223)
        at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:219)
        at sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:83)
        at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:106)
        at myApp.javabase.utils.c.<init>(Unknown Source)

I tried System.setProperty("sybase.allow.native.lib", "true"), this works for debug and local build, but not for release build. In release, there are compiled dlls (39) in bin folder. If I delete at least one of them (any of them; tested 4 dlls) or all of them, I get no error - this is strange.

Another workaround is to install Java on path without Japanese characters and add this path to environment variables, but this is not what I need. Not all users have application installed locally.

Code:

package myApp.javabase.utils;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

public class ClipboardImage implements ClipboardOwner
{
  public ClipboardImage( Image img )
  {
    TransferableImage trImg = new TransferableImage( img );
    Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
    
    // allow native library -> java.lang.ClassLoader.loadLibrary0
    //System.setProperty("sybase.allow.native.lib", "true");
    cb.setContents( trImg, this ); // here is the problem
  }
  // another code
}

I did find this, System.load(File) to load the library, but is it necessary? Might be there other solution?

stojelenov
  • 13
  • 5
  • Are you sure that error is due to the use of a Japanese locale? It looks like an issue with the way the application was packaged. Does the exact same application work properly on the same machine if the locale is set to English? – VGR Sep 12 '22 at 14:26
  • @VGR, thanks for your comment. I am sure, screenshot is created and I get no error if locale is set to English. Both: path and locale have to be Japan, then I get the error. – stojelenov Sep 13 '22 at 06:26

0 Answers0