JavaPOS printing text throws JposException - java

I had a lot trouble to setup a applet to work with an Epson TM-T88V pos printer. Now I can send the command for the cutter and it works. But printing any other text is not possible.
The following jpos.JposException occurs:
jpos.JposException: UnicodeDLL:-10An undefined parameter value was set.
at jp.co.epson.upos.T88V.pntr.T88VService.createNormalData(Unknown Source)
at jp.co.epson.upos.core.v1_13_0001.pntr.CommonPrinterService.executeNormalPrint(Unknown Source)
at jp.co.epson.upos.T88V.pntr.T88VService.printNormal(Unknown Source)
at jpos.POSPrinter.printNormal(Unknown Source)
at de.develman.pos.printer.Printer.printReceipt(Printer.java:58)
at de.develman.pos.ui.action.PrintAction.actionPerformed(PrintAction.java:22)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
...
My code looks as follows:
private void initPrinter() throws JposException {
ptr.open("POSPrinter");
ptr.claim(1000);
ptr.setDeviceEnabled(true);
ptr.setMapMode(POSPrinterConst.PTR_MM_METRIC);
}
private boolean printerUseable() throws JposException {
// check if the cover is open
if (ptr.getCoverOpen() == true) {
// cover open so do not attempt printing
System.out.println("printer.getCoverOpen() == true");
return false;
}
// check if the printer is out of paper
if (ptr.getRecEmpty() == true) {
// the printer is out of paper so do not attempt printing
System.out.println("printer.getRecEmpty() == true");
return false;
}
return true;
}
public void printReceipt() {
try {
initPrinter();
if (printerUseable()) {
ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, "1\n");
ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, PAPERCUT);
}
} catch (JposException e) {
// display any errors that come up
e.printStackTrace();
} finally {
// close the printer object
try {
ptr.setDeviceEnabled(false);
ptr.release();
ptr.close();
} catch (Exception e) {
}
}
The exceptions points to the line:
ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, "1\n");
If I run the code from eclipse everything works fine. If I remove the line, the cutter works fine. But if I want to print any text, the given exception is thrown.
What is my problem here?

I have implemented JavaPOS with an Epson TM-T88V printer and I had the same error, but I was able to resolve the error with the sample code from this link:
http://jpos.1045706.n5.nabble.com/file/n2250344/StarReceiptTest.java
Look at the part that starts and terminates a printing transaction.
Hope it helps.

I had the same Problem.
To fix this I have deinstall the Epson JavaPOS-ADK and reinstall it. While reinstalling the ADK again I have checked that I have select the right jpos.xml (that jpos.xml what I also used in my application). After that the error was gone ...
Hope this helps some other guys with the same problem ...

Same problem here, the other answers didn't help for my issue.
I was able to install Epson_JavaPOS_ADK_11120.exe on a Win 10 64 with the steps below, it took me 3 days to figure this out:
remove any version of Java from Control Panel, reboot
install jdk-6u45-windows-i586.exe, reboot
replace java.exe, javaw.exe, javaws.exe in C:\ProgramData\Oracle\Java\javapath with the executable provided by the new Java installation from C:\Program Files\Java\jre6\bin
execute the Epson installer as Administrator
restore your system when done

Related

Externally executable application fails for some application?

I'm wanting to launch the program from a Java application, with some luck. Most programs are started without problems, but some seem to not execute properly(?).
The code I'm using is very simple:
private static void exec() {
ProcessBuilder builder = new ProcessBuilder("C:\\Users\\Fillipuster\\AppData\\Local\\Discord\\Update.exe");
try {
builder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
...and works for almost all executables (*.exe). Discord is purposefully placed in the example, as it is one of the programs that cause this problem. (along with Messenger For Windows and GOG Galaxy).
The behavior is simple, and the same for all executable that causes this; a command prompt quickly pops into existence and then promptly disappears (pun intended) - resulting in the application not being launched.
Sifting through Google and Stack Overflow proved a futile effort, and at this point, I'm at a complete loss.
Any help/input is much appreciated.
Thanks to John, who pointed out that even launching the the Update.exe file "manually" results in the same behavior, I've found the problem.
It seems that when launching Discord successfully, one is actually launching a shortcut that gives a parameter to the executable. In this case:
--processStart Discord.exe
This means that the following code will in fact start Discord:
private static void exec() {
ProcessBuilder builder = new ProcessBuilder("C:\\Users\\Fillipuster\\AppData\\Local\\Discord\\Update.exe", "--processStart", "Discord.exe");
try {
builder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
Thanks to John and all the other commenters.

java rmi simple project classNotFoundException binding registry

Ok, I'm sure this should be pretty easy, but I'm fairly new to Java (I'm more a .NET boy :P) and after following every single recommendation I found here to no success, I think it's time to step back and ask.
I'm trying to start a simple rmi project with a client, a server and a common project where common interfaces are defined. I've just implemented my server code, and when I try to run it to check if everything is fine, I get struck on a java.lang.ClassNotFoundException.
After following several answers on similar issues, I'm fair sure that my problem comes from rmiregistry running on a different location than my project.
I use following code to set registry codebase:
public class Utils {
public static final String CODEBASE = "java.rmi.server.codebase";
public static void setCodeBase(Class<?> c) {
String ruta = c.getProtectionDomain().getCodeSource().getLocation().toString();
String path = System.getProperty(CODEBASE);
if (path != null && !path.isEmpty()) {
ruta = path + " " + ruta;
}
System.setProperty(CODEBASE, ruta);
}
}
Then, I try to start my server code with this main class:
public class MainRegulador {
public static void main(String[] args) throws AccessException, RemoteException, NotBoundException {
Utils.setCodeBase(IRegulador.class);
Registry registro = null;
Remote proxy = null;
try {
Regulador myReg = new Regulador();
proxy = UnicastRemoteObject.exportObject(myReg, 36510);
registro = LocateRegistry.getRegistry();
registro.rebind("Distribuidor", proxy); //this is the line where exception is thrown
System.out.println("El Regulador está corriendo. Pulse ENTER para finalizar el proceso.");
System.in.read();
} catch(Exception ex) {
System.out.println("No se ha logrado inicializar el Registrador");
System.out.println(ex.getMessage());
} finally {
if (registro != null && proxy != null) {
registro.unbind("Distribuidor");
UnicastRemoteObject.unexportObject(proxy, true);
}
}
}
}
But when I run it, always get a java.lang.ClassNotFoundException at IRegulador interface.
Now the fun part:
I've printed to console java.rmi.server.codebase value, and it's pointing to bin folder of project where IRegulador interface is defined. (file:/F:/Practicas%20y%20dem%c3%a1s/Sistemas%20Distribuidos/common/bin/)
Obviously, that project is also set in the classpath of server project
(Regulador)
Workspace and rmiregistry are on different disks
Despite all, it doesn't seem a global classpath problem, as Utils class is on the same project as IRegulador interface, and it runs before the exception is thrown (as java.rmi.server.codebase is correctly set).
I've tried to set the classpath of rmiregistry before calling it (although it is directly discouraged on some answers), but nothing changed.
I've also tried to start rmiregistry.exe from Regulador project bin folder, but also seemed to don't change anything.
Coming from a .NET background, I've always found these classpath issues confusing, and this one is starting to consume much more time than I suspect it deserves. I'm in desperate need of help.
UPDATE: I'm starting to think that the problem is within the url it's passed to the codebase from IRegulador.class. If I paste it into windows explorer, the SO is unable to locate it, so I supose that it's being built with some structure problem that prevents the registry to reach the route:
file:/F:/Practicas%20y%20dem%c3%a1s/Sistemas%20Distribuidos/common/bin/
UPDATE2: I thought path route could be too complex, so I decided to simplify it and strip it from any non-straight character. Now codebase value is
file:/F:/Practicas/SD/common/bin/
However the problem persists, I don't know why rmiregistry is unable to reach that folder.
Then I decided to move the whole project to the same disk where rmiregistry is executed, and see if it changes anything. But nothing changed, same problem.
Ok, finally I got it working...
I've just copied rmiregistry.exe into the common/bin folder and launch it directly from there (previously just had called from there).
This seems to fix the problem with the routes (actually it makes the route available to the registry as it's on the same folder, probably all my codebase writting code is superflous now).

im4java throws FileNotFoundException error

I need to use ImageMagic in my java project.
I already installed ImageMagic-7.0.3 on Windows 10
(command line works fine)
Then, i added dependency to im4java in maven file. When i try to do some action like:
public static void main(String[] args) {
String imPath="C:\\Program Files\\ImageMagick-7.0.3-Q16";
ConvertCmd cmd = new ConvertCmd();
cmd.setSearchPath(imPath);
IMOperation op = new IMOperation();
op.addImage("biuro.jpg");
op.negate();
op.addImage("biuro_new.jpg");
try {
cmd.run(op);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IM4JavaException e) {
e.printStackTrace();
}
System.out.println("works");
}
i get following error
org.im4java.core.CommandException: java.io.FileNotFoundException: convert
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at Main.main(Main.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.io.FileNotFoundException: convert
at org.im4java.process.ProcessStarter.searchForCmd(ProcessStarter.java:661)
at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:399)
at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
... 6 more
I went trough half of Internet. Read half of google. There was only one small advice saying "have you installed Visual C++ Redistributable and reboot?" That was the solution.
ImageMagick worked in command line, so I did not expected requirement of that type. Moreover I did not find a thing about it in both - im4java and ImageMagick reference.
Hope this will be helpful, and noone ever will waste about 5h of life searching the answer.
Set the user variable under environment variable,Variable name as IM4JAVA_TOOLPATH
and Variable Value as C:\Program Files\ImageMagick-7.0.3-Q16.
after that kill all the java process and try to run the program.
Other way you can set the global search path like below:
String myPath="C:\\Programs\\ImageMagick;";
ProcessStarter.setGlobalSearchPath(myPath);
This will override your user environmental variable.
Also refer the documentation for more setup related info in detail http://im4java.sourceforge.net/docs/dev-guide.html
After spending a lot a hours in order to research why I had that issue, the solution is : you need to uninstall then reinstall ImageMagick with "Install legacy utilities (e.g. convert)" during the setup.

Disabling the Keyboard and mouse

I am a newbie to JNA and I have this code which is supposed to block the input by calling the dll file in win7. But when I run this code, nothing happen. There is no compilation error and I can't figure out why it doesn't block my keyboard and mouse. Please guide me.
public class BlockInput {
public static void main(String[] args) {
NativeLibrary lib = NativeLibrary.getInstance("user32");
Function fun = lib.getFunction("BlockInput");
System.out.println("Lib :" + lib + ".\nFun " + fun + ".");
fun.invoke(new Object[]{Boolean.TRUE});
try {
Thread.sleep(10000);
} catch(InterruptedException ie) {}
lib.dispose();
}
}
EDIT : With Native.getLastError(); I came to know that whicle accessing the dll file I recieve the error 5 (Access denied).Is there any possible way to gain access,so that I can make it work?
If you are running on Windows Vista or Windows 7, you might need to run the program as administrator. Make a batch file that runs your Java class to make things easier.
Try This - A Native Global keyboard and mouse listeners for Java.
JNativeHook

java.lang.InternalError: Location with invalid code index... What?

I am creating a j2me application, and when I try to debug it in netbeans, I get an error when I reach a point in my code.
The code is as follows
class MyClass{
public MyClass()
{
OtherClass oc = new OtherClass();
oc.MyMethod();
}
}
The other method is as follows:
public void MyMethod()
{
boolean isValue = true; // I get an exception right here...
if(...) { /*Code not reached*/ } ...
}
The exception I get looks like this:
java.lang.InternalError: Location with invalid code index
at com.sun.tools.jdi.ConcreteMethodImpl.codeIndexToLineInfo(ConcreteMethodImpl.java:167)
at com.sun.tools.jdi.LocationImpl.getBaseLineInfo(LocationImpl.java:108)
at com.sun.tools.jdi.LocationImpl.getLineInfo(LocationImpl.java:122)
at com.sun.tools.jdi.LocationImpl.sourcePath(LocationImpl.java:187)
at com.sun.tools.jdi.LocationImpl.sourcePath(LocationImpl.java:182)
at org.netbeans.modules.debugger.jpda.models.CallStackFrameImpl.getSourcePath(CallStackFrameImpl.java:238)
at org.netbeans.modules.debugger.jpda.ui.EditorContextBridge.getRelativePath(EditorContextBridge.java:355)
at org.netbeans.modules.debugger.jpda.ui.CurrentThreadAnnotationListener$AnnotateCallStackTask.run(CurrentThreadAnnotationListener.java:344)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Does the JRE used by your emulator match the JDK version you built the code with? Since this is an internal error, either a mismatch has occurred, data corruption (e.g., the JPDA injection), or an actual bug in the JRE.
From the looks of the error, the failure is in trying to find the code line that matches up with the exception. If you turn off JPDA debugging, or run it outside of netbeans, do you get the error?

Categories