Morena 6 support resources
Please check the FAQ section of our site for an answer to your question before you contact our technical support.
If you need help with our product, please send a message to twain@gnome.sk .
If you need help with a TWAIN source manager or driver, please use the TWAIN mailing list archive .
If you prefer conventional communication, you can also call +421 903 757825.
 
 
Frequently asked questions
Does Morena run in the 64-bit mode of MS Windows? Does Morena run in the 64-bit mode of Java?
Yes, Morena runs under MS Windows in 32-bit as well as 64-bit mode. To date, 64-bit mode in MAC OS X is not supported.
All components, i.e. Java JRE, Twain DSM, and the Twain driver, have to be in the same mode; in other words, the whole chain has to either be in 32-bit mode or in 64-bit mode, not a combination of the two. According to our information, the default installation of 64-bit Windows contains the 32-bit mode of Twain DSM. If you want to use the 64-bit Twain driver, you will probably need to download the 64-bit version of DSM from www.twain.org . Do not forget that, in case of applets, if you are using the 64-bit version of an Internet browser, the same type of Java - 64 bits - will be loaded to run the applet. Please also note that many Twain drivers on the market, even those, which are labeled "Supports 64-bit Windows" are in 32-bit mode.
I'm trying to deploy an app that uses Morena. I can get the app to start, but I get the following error when I try to scan: java.security.AccessControlException: access denied
The most common cause of this error report is that you forgot to sign your jar files .
Is it possible to get images from a remote network device using its IP address?
Twain is not designed for network communication. To scan images with Twain, you have to use your application in conjunction with Twain Data Source Manager (DSM) and a Twain driver on the client computer. The same also applies to network scanners. When using a network scanner, its Twain driver located on the client computer is just a "proxy" which receives communication from the DSM and forwards it to a network IP address. So, assuming that the client computer has DSM as well as a Twain driver installed, Morena will work correctly with network scanners. In fact, Morena will not know whether the source is connected directly or it is functioning as part of a network. In our office, we have a Lexmark X544 network scanner. It has a Twain driver and it is connected to the ethernet network, not to the computer's USB. This configuration works well.
Sane, on the other hand, is completely different. It is designed from the beginning as a network API. You can acquire images from the scanner connected to the computer through the network. The only requirements are that the computer where the scanner is connected supports Sane and Sane's network daemon. Again, you can test it with our online MorenaStudio applet.
When I use the Morena library, I get this error report: java.lang.NoClassDefFoundError: Could not initialize class.
The cause of this error is often in the license. Your trial license may have expired, for example.
I often get an unexpected "java.lang.NoSuchMethodError: SK.gnome.twain.TwainManager.selectSource..." exception.
Typically there is a version mismatch somewhere. Cleaning is a good first step to solve this problem.
I am trying to figure out how to scan using a duplex scanner. Does Morena support this?
To find out if duplex scanning is supported by the Twain driver, call the twainSource.getDuplex() method. If duplex scanning is supported, call the twainSource.getDuplexEnabled() method to find out if duplex scanning is enabled. To turn duplex scanning on, call twainSource.setDuplexEnabled(true);
How can I get images of both sides?
You can use the standard ADF technique:
      do 
      {
        Your scanning activity. 
      } while (source.hasMoreImages());
      
How can I detect a paper jam?
The Twain driver should report a paper jam to the condition code status. In case of a paper jam, it should return TWCC_PAPERJAM=20. Many drivers do not support this feature. You can experiment with the getConditionCode, getResultCode methods on your specific hardware.
ImageConsumer constants are useful in detecting that a problem of some sort has occurred. (You will not be able to detect that it is a paper jam in particular that has occurred, however.) There are three possible status values:
IMAGEABORTED = The image creation process was deliberately aborted.
IMAGEERROR = An error was encountered while producing the image.
STATICIMAGEDONE = The image is complete and there are no more pixels or frames to be delivered.
You can also receive these values using the getStatus method of the MorenaImage class.
Scanning or GUI loading is extremely slow.
According to our information, there are some scanners (CanoScan LiDE 20/30/50/60, Canon CR-180, DR-1210C, HP Scanjet 7800, Kodak i1220) which scan correctly from Java applications and WebStart applications, but scanning via applets takes too long. Morena is used with hundreds of scanners. We do not have the similar reports related to other scanners.
According to our tests, applet scanning speed does not depend on the operating system version, or USB type. It seems that there could be a correlation between the amount of the computer memory and scanning speed. We have also tested applets developed by other developers; the speed behavior was the same. The scanning speed is not dependent on the Morena Framework. We suspect that the problem may be caused by the following: Java JRE can manage how much stack and heap space it requires, but it cannot influence the stack and heap space requirements of the native JNI library. Because of this, the combined Morena JNI library , Internet browser, and Twain driver do not have enough heap or stack space.
Is it possible to use Morena with Citrix?
We have no experience with Citrix, but one of our customers sent us the following message: "I have tested it against Citrix Presentation Server version 4.5 and 5.0, it works fine (with Citrix XenApp Client version 11.0.0.5357)." This customer agreed to let you contact him if you have any further queries.
We use File transfer mode. The scan runs through without any errors or java exceptions, but the file we try to create, 'myimage.jpeg', fails to appear. Instead we get another file, TWAIN.TMP, in its place. Could you please help us with this?
File transfer mode is completely managed by the Twain driver. The developer cannot influence it. But here are some of our ideas:
Maybe your Twain.tmp file is actually the correct jpg file, but for some reason the Twain driver is not able to rename it. Try to change Twain.TMP to myimage.jpeg or myimage.bmp.
Check write permissions. Check access rights in the directory where the Twain driver tries to save the image.
Morena uses a native library. Because of this, if you use it in an applet, you need to sign that applet so that the Internet browser delegates sufficient access rights to it (to run a native code, not a Java code). You sign applets (jar files) with the certificate. You can sign your jar files with certification generated by the Java jarsigner and keytool. For more trustworthy access, however, use certificates generated by some certification authority. Here is an example of how to sign examples.jar using your own certificate:
      rem Let’s assume that the working directory is examples. 
      rem Change the path below to your Java JDK path=%path%;"C:\Program Files\Java\jdk1.6.0_07\bin"
      
      rem Creates bin directory in order to compile java files into it. 
      mkdir bin 
      javac -cp ../lib/morena.jar -d bin src/*.java 
      jar cf examples.jar -C bin .. 
      
      rem Password is 123456 
      keytool -genkey -alias yourcompany -keypass 123456 
      jarsigner examples.jar yourcompany 
      pause
      
See e.g. the following link for more information.
Can I capture images from multiple sources, e.g. two cameras, simultaneously?
No, because neither Twain nor Sane technologies allow this.
Is it possible to redirect the debug log to a file instead of a console?
The debug output is written to the standard error output stream. You can redirect it in two ways:
Directly in Java using System.setErr(PrintStream err) method.
Using the shell script of the operating system. For example in Microsoft Windows you can do the following: java ..... -Dmorena.debug=true MorenaStudio 2>log.txt
How do I detect a blank page?
To detect a blank page document, the developer can use the setJobControl(int value) method with the following values for the TwainConstants class:
TWJC_NONE No job control.
TWJC_JSIC Detect and include job separator and continue scanning.
TWJC_JSIS Detect and include job separator and stop scanning.
TWJC_JSXC Detect and exclude job separator and continue scanning.
TWJC_JSXS Detect and exclude job separator and stop scanning.
TwainSource.endOfJob() is the right method to test the end of job.
Unfortunately, there is no guarantee that the method is supported by the Twain driver. You can create YourOwn class with ImageConsumer interface. You receive image data in YourOwn class and store it to a data structure, e.g. an array. You can then parse that array. This is a good way to detect blank pages if the Twain driver does not support that capability.
I have successfully deployed Morena in my Java web start application to Windows machines. Now I would like to make it possible for Mac OS X users to do scanning. Do I just add the morena_osx.jar file as a resource in my JNLP file, in addition to the existing morena_windows.jar?
It's simple. Just add morena_osx.jar to the existing jnlp file at the same place, where morena_windows.jar is located.
The trial downloads only include MS Windows and MAC OS X. How can we get the Linux libraries?
To use Morena Framework in Linux, you can download the arbitrary type of our distribution packages - MS Windows or MAC OS X. We distribute the Morena Framework in two distribution packages due to the Twain interface. Linux supports the Sane interface and it is included in both packages.
  1. Check whether you are able to scan images with the Sane interface using a native Sane application, e.g. scanimage.
  2. If 1. is OK, repeat 1., but using a Sane network daemon. See http://penguin-breeder.org/sane/saned/ for more information on how to configure it.
  3. If 2. is OK, run our MorenaStudio and select the Sane button.
Even when I use setVisible(false) to disable the prompt that the user can specify the scanning properties in, the dialog with the option to "cancel" the scan still appears during the scan. I really need to get rid of this. Is there a way to hide this dialog as well?
The setIndicators(false) method of TwainSource class is intended for this purpose.
Is it possible to call Morena from Javascript?
Designing web scanning via JavaScript is possible, but not trivial. Our advice is to use an applet on its own, without javascript. This will make your developer life much simpler. A MorenaStudio source code is available as a source of inspiration. If you must use javascript, you should be aware of this threads problem:
Because of Twain specifications, you need to run a complete scan in one thread. In our experience, some Internet browsers use a special thread for java applets and a different thread for javascript communication. You need to design a solution, in which the complete communication with Morena will be in one thread.
How can I customize the scanning area size programmatically so the users don't have to see the scanner interface?
You can call setFrame(double left, double top, double right, double bottom) of the TwainSource class. It uses the units set by the setUnits(int unit) method (Some Twain drivers ignore the unit set by the setUnits capability and use their own default one.). For example, to acquire the A4 paper format, call
twainSource().setUnits(TwainConstants.TWUN_CENTIMETERS);
twainSource().setFrame(0,0,20.99, 29.70);
You can try the SupportedSizes capability. SupportedSizes is a capability intended for Twain sources that support fixed-size scanning areas. You need to choose only one value during negotiation with the Twain source. You can ask for supported sizes:
twainSource.getSupportedSupportedSizes()
or set a size:
twainSource.setSupportedSizes(TwainConstants.TWSS_A4);
Some Twain drivers do not support this capability.
You can also try to experiment with the following capabilities:
twainSource.setUndefinedImageSize(true);
twainSource.setAutomaticBorderDetection(true);
We sometimes see the TWAIN UI being opened behind the browser window in certain environments (or perhaps with certain TWAIN drivers, not 100% sure). Is this a known issue and is there any resolution you recommend?
Yes, we occasionally receive emails describing the behavior you write about. TWAIN UI windows are opened by the Twain Data Source Manager (DSM) and the Morena Framework cannot influence it.
We have a solution for the "Select source" dialog window. TwainManager has two types of selectSource methods:
selectSource(TwainSource defaultSource) = this method asks the DSM to pop up the select source dialog window. From time to time, the select source window pops up behind the application window. selectSource(java.awt.Component parent, TwainSource defaultSource) = Our own implemented Java dialog box. It is always on top.
You can use our pure Java User Interface dialog window. See our MorenaCapabilities example. It is always on top.
For the main Twain UI window, one of our customers sent us this workaround: There are setFront() and setBack() methods in the Java. (In the Frame or Window class, I think.) Just before acquiring the image call the setBack() method of your Frame and after acquiring the image call setFront().
Is there a way to make the program select the source without user intervention?
You can use TwainManager.getDefaultSource() to use the last used source or TwainManager.listSources() to obtain an array of sources. The application can call the toString() method of the source to parse a source name.
I received the OutOfMemoryError exception.
The quick solution is to increase JRE heap size through the -Xms and -Xmx system properties, for example -Xms512M -Xmx512M. If you are using an applet, you need to setup these system properties on the side of the computer running the applet. (E.g. Control Panel/Java/Java Applet Runtime Settings/Java RuntimeParameters/ -Xms512M -Xmx512M) Beginning with Java version 1.6.0_10 Sun introduced the new JRE plugin for Internet browsers. It allows you to set the applet properties via jnlp on the server side.
One scanned image (A4, 300 DPI, RGB) could be more than 79 MB, so it is a good idea not to have all scanned images in the memory.
How can I find out which capabilities my Twain driver supports? Which options does my Sane backend support?
For Twain, you can run our TwainAutomatedTest.java (test.bat, test.sh located in the examples directory). It will write all supported capabilities to the twainAutomatedTest.txt file.
In both interfaces, Twain as well as Sane, you can run our MorenaCapabilities example:
  1. First select your Twain or Sane source.
  2. Click the "Custom dialog window"/"Select capabilities". The dialog window will pop up all supported capabilities/options.
Is Morena capable of capturing video?
Morena is a Java wrapper for the Twain and Sane interfaces. Twain as well as Sane specifications allow the capture of static images only.
I use an applet with Morena on two different pages and when I run the applet from the first page, everything works fine, but if I close the first page and run the applet from the second page, I get the following java.lang.UnsatisfiedLinkError exception : SK.gnome.twain.TwainManager.initialize(I[B[BZ)V.
First, check whether you use the same Morena jar files in both pages.
We think that the cause of your problem is this: "The virtual machine does not allow a given JNI native library to be loaded by more than one class loader. Attempting to load the same native library by multiple class loaders causes an UnsatisfiedLinkError to be thrown. (http://java.sun.com/docs/books/jni/html/design.html#8148) We did not find any information on whether it is possible to unload a JNI library (or the applet's classloader) without closing the Internet browser.
You can add a test debug output to your applets: getClass().getClassLoader().hashCode(). We believe that you will receive a different output.
Summary: It is not possible to load a JNI native library using two different applet classloaders. We were able to run two applets with Morena successfully only when both applets were loaded from the same web page.
Can I save the scanned image as a PDF? I know my scanner has a “generate pdf document” option.
Saving to a PDF file format is not part of Twain or Sane specifications. If your scanner supports it, it is using some add-in designed by the driver developers beyond the Twain specification. Morena communicates with scanner via Twain (or Sane) interfaces only.
Morena Framework delivers scanned data via the standard Java ImageProducer interface. So the question is: "How can we save acquired data in the PDF file format, if it is produced via ImageProducer interface?" It is the same as if you produce image data from the image file. Regarding the PDF file format, we have feedback from our customers indicating that they have good experiences with iText, a free library for generating PDF files.
Here is a snapshot demonstrating how to save to a PDF file using iText library:
      TwainSource source = TwainManager.selectSource(null); 
      MorenaImage morenaImage = new MorenaImage(source); 
      Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);
      
      com.lowagie.text.Image iTextImage=com.lowagie.text.Image.getInstance(image, null);
      iTextImage.setAbsolutePosition(0, 0);
      Document document=new Document(iTextImage); 
      PdfWriter writer=PdfWriter.getInstance(document, tmp); 
      document.open(); 
      PdfContentByte cb=writer.getDirectContent(); 
      cb.addImage(iTextImage); 
      document.close();
      
Of course, you can also use your preferred PDF libraries.
How can I save the scanned image?
The Morena Framework produces acquired data via the ImageProducer interface. So the question is, how can you save an image, if the image data is produced via the ImageProducer interface.
In all versions of Java starting with Java version 1.2 = there has been a com.sun.image.codec.jpeg in Sun's standard Java distribution.
Since Java version 1.4.1 = there has been a javax.imageio in the standard Java distribution. It offers writing to PNG and JPEG formats.
Since Java version 1.5 = writing to a BMP format has been a part of javax.imageio package. The imageio package offers saving to TIFF with I/O Tools.
Java Advanced Imaging (JAI) offers writing to many formats, including TIFF.
Here is an example of how to save an image using ImageIO:
      TwainSource source = TwainManager.selectSource(null); 
      MorenaImage morenaImage = new MorenaImage(source); 
      Image image=Toolkit.getDefaultToolkit().createImage(morenaImage); 
      BufferedImage bimg=new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
      bimg.createGraphics().drawImage(image, 0, 0, null);
      ImageIO.write(bimg,"jpg",new File("test.jpg"));
      
Here is an example of how to save an image using com.sun.image.codec.jpeg.*:
      TwainSource source = TwainManager.selectSource(null); 
      MorenaImage morenaImage = new MorenaImage(source); Image
      image=Toolkit.getDefaultToolkit().createImage(morenaImage); 
      File f=new File("SaveTest.jpg"); 
      BufferedImage bimg=new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); 
      bimg.createGraphics().drawImage(image, 0, 0, null); 
      FileOutputStream out=new FileOutputStream(f); 
      JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(out); 
      JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam(bimg); 
      param.setQuality(1.0f, false); 
      encoder.setJPEGEncodeParam(param);
      encoder.encode(bimg); out.close();
      
If you are using a Twain interface, you can use file tranfer mode to save the acquired image directly from the Twain driver.
What is the MorenaImage class intended for?
MorenaImage class serves as a simple memory buffer for acquired images. Each invocation of startProduction() on Morena sources ImageProducer interface is a new acquisition on your imaging device. You have to cache an image if you want to use it for repetitive drawing, saving to a file or other manipulation. Either MorenaImage or BufferedImage can be used.
Morena produces scanned images via the ImageProducer interface. You can design your own class with the ImageConsumer interface to manage acquired data directly. To receive the standard Image class, you can use the following code design:
      SaneConnection sc = SaneConnection.connect("localhost"); 
      SaneSource source=sc.selectSource(null,null); 
      or 
      TwainSource source = TwainManager.selectSource(this,null);
      
      Image image=Toolkit.getDefaultToolkit().createImage(source); 
      MediaTracker tracker=new MediaTracker(this); 
      tracker.addImage(image, 0); 
      try { tracker.waitForAll(); } 
      catch (InterruptedException e) 
      { e.printStackTrace(); 
      } 
      tracker.removeImage(image);
      
I have serious problems getting a BufferedImage image from MorenaImage.
You can use the following code design to create BufferedImage:
      MorenaImage morenaImage = new MorenaImage(source); 
      Image image=Toolkit.getDefaultToolkit().createImage(morenaImage); 
      BufferedImage bimg=new BufferedImage(image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_INT_RGB); 
      bimg.createGraphics().drawImage(image, 0, 0, null);
      
(You can omit MorenaImage class if you prefer.)
Is Morena MAC OS X 10.6 Snow Leopard compatible?
Morena is ready for Snow Leopard. There is one requirement: You need to run it in 32-bit mode. Java in Snow Leopard is, by default, set up as 64-bit. You need to set it up so that it runs itself as 32-bit. (Applications/Utilities/Java Preferences). Note that there are separate settings for Java applications and for Java applets. Furthermore, in the case of applets, you need to use Internet browsers in 32-bit mode. Safari in Snow Leopard runs as 64-bit, by default. In Safari, all you need to do is highlight Safari in Finder, ctrl-click on it and select Get Info, and enable the "Open in 32-bit mode" checkbox under the General section. FireFox (or at least the version we tested) runs the 32-bit version by default.
My application crashed JVM 1.6 with EXCEPTION_FLT_STACK_CHECK error
There is a known bug in Java version 1.6. To workaround, use Morena version 6.3.2.4 or higher, or use -Xcheck:jni in your Java command line (there will be plenty of warnings from the Java interpreter), or use Java 1.5 or lower.
Is there any difference between the MS Windows and Mac OS release?
From the Java developer’s point of view there is no difference. API is the same for all environments. The security constraints under Mac OS X are different to those under MS Windows.
What is the difference between the trial version and the full version?
The trial version and the full version have the same features. They differ in the license statement displayed to the Java console.
Could you send me some information about the licenses, the shipping and the payment methods?
Our license policy: You need as many licenses, as there are developers working on the project where the Morena Framework is included. You can include the Morena Framework in an unlimited number of your applications (and applets) and distribute it to an unlimited number of customers. Your customers have to be "end users", i.e. you are not allowed to offer your applications with the Morena Framework to other developers. You are not allowed to sell the stand-alone Morena Framework. For the source code license, one license is enough for the whole organization.
Shipping: You can download a full product including an evaluation license from our try & buy page . After purchasing a commercial or obtaining a educational license you will receive morena_license.jar file as an email attachment. Then just replace the evaluation morena_license.jar file contained within product package with the new file.
Payment methods: You can buy a commercial license on-line from our try & buy page . If you prefer, when we send you an invoice, you can pay by account transfer into our bank account or by money order, whichever you prefer.
Where can I find more information about Twain specification?
You can find it at www.twain.org .
Is Morena pure Java(tm) code?
No, it is not. Because of the Twain specification design, it is not possible to implement the TWAIN client to be platform independent. So far, it is ported to Windows and MacOS X only. The Sane interface is implemented as pure Java.
Why does my scanner not accept my settings?
Not every scanner/camera driver implements the full Twain/Sane specifications, e.g. some of them allow hiding the user interface, some of them do not.
My scanner supports 12/16 bit scanning. How can I set it through Morena?
12/16 bit scanning is not defined by the Twain specification and thus it is not supported by Morena.
What is a TwainProxy application?
On the MacOS X platform it is not possible to use a shared library with the own user interface from JNI code. That's the reason Morena delegates this to a standalone application controlled through IPC.
What is a behaviour mask?
Because of some bugs in TWAIN drivers for some popular scanners, Morena implicitly works in a workaround mode. To turn off the workaround mode use setBehaviorMask(0) on TwainSource instance. The image acquisition can be much more efficient in this case, but on the other hand, if your scanner's driver has the mentioned bug, this will crash your application.
What can I do about the "Current thread is not owner" error?
Morena is not thread safe, because the underlying technology (TWAIN and SANE) is not thread safe. But, in general: Open, negotiate with the DSM and the source, and close Morena from the same thread. An example of how to design a thread safe application is our MorenaStudio.java located in the examples/src directory of the distribution package.
What can I do about "The license purchased on ... is not valid for this build!" error?
Your license may be still valid for older versions of Morena, but not for this one. You need to buy an update to receive a valid license for this version of Morena.
What can I do about "The license expired on ...!" error?
Trial licenses and some non-commercial licenses have a limited lifetime. You need to obtain a new license file.
What can I do about the "No valid license found" error?
Morena license files are stored in morena_license.jar by default. There are property files and their digital signatures inside. Make sure that this archive is listed in your class path and is loaded by the same class loader as the Morena classes.
How can I find out what's wrong?
Turn Morena's debug mode on (-Dmorena.debug=true system property) and see to the generated log. You can send the log together with your error report to twain@gnome.sk.
One common good step to solve the problem is cleaning:
  1. Delete (backup first, if needed) all morena.jar, morena_windows.jar, morena_osx.jar, morena_license.jar from the WHOLE disk. (If you used a version from before 2005, also delete javatwain.jar, javatwain_license.jar, javatwain.dll, javatwain_debug.dll.) Delete the .morena directory from the user's home directory. Pay special attention to the JRE/lib/ext directories.
  2. Test our MorenaStudio applet.