python-zxing
python-zxing copied to clipboard
Could not find or load main class com.google.zxing.client.j2se.CommandLineRunner
I am getting this error when trying to run this code - it appears zxing is installed:
computer$ java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner Decode barcode images using the ZXing library
usage: CommandLineRunner { file | dir | url } [ options ] --try_harder: Use the TRY_HARDER hint, default is normal (mobile) mode --pure_barcode: Input image is a pure monochrome barcode image, not a photo --products_only: Only decode the UPC and EAN families of barcodes --dump_results: Write the decoded contents to input.txt --dump_black_point: Compare black point algorithms as input.mono.png --crop=left,top,width,height: Only examine cropped region of input image(s)
It appears I just don't know that much about java - I need to find where zxing got installed.
Did you ever find a solution to this issue?
@BrandonCopley: Were you running python-zxing on Windows or Linux?
I am running this on Mac (Unix). However, it's been a long time since I've looked into this.
Hmm, odd. The path separator should be the same on OS X as Linux, or at least I thought it was. What folders do/did you install zxing to?
I installed the zxing to c:/zxing/"this is where the core and javase subdirectories are with the respective .jar files and python zing to C:/Python27/Lib/site-packages/zxing
On Wed, Aug 12, 2015 at 1:34 PM, David Manouchehri <[email protected]
wrote:
Hmm, odd. The path separator should be the same on OS X as Linux, or at least I thought it was. What folders do/did you install zxing to?
— Reply to this email directly or view it on GitHub https://github.com/oostendo/python-zxing/issues/6#issuecomment-130285101 .
@BrandonCopley: Let me know if you have a chance to try it out again on OS X. I've removed all of the hard-coded separators, which should fix it. I might still be overlooking something.
https://github.com/Manouchehri/python-zxing/tree/osx (I haven't tried my last commit, I wrote it on my tablet; should work though.)
I'll probably get around to setting up a quick unit test to run on Travis CI as well.
Hello, the link https://github.com/Manouchehri/python-zxing/tree/osx is leading to a 404 error...
I am also getting this error "Error: Could not find or load main class com.google.zxing.client.j2se.CommandLineRunner" too when run the follow script:
from zxing import * reader = BarCodeReader() barcode = reader.decode("barcode_01 roi_1.jpg") print barcode
Error: Could not find or load main class com.google.zxing.client.j2se.CommandLineRunner <zxing.BarCode instance at 0x10ad71cb0>
I am on Mac... what could I do to fix it?
I think you are not specifying the path were zxing
is installed.
You need to instantiate a reader as follows :
reader = BarCodeReader('<path where the zxing folder is present>')
If everything else was right, this should do it. :)
@chuckytah Ugh, that was my mistake... I deleted the branch since I thought I had already merged in the changes; turns out I didn't.
I'll have to poke at this again later.
Well i have used zbar now. I was able to use zxing but it was taking too much time to decode the barcode.
Thanks anyway. Keep the good working.
Ines Em 19/01/2016 20:02, "David Manouchehri" [email protected] escreveu:
@chuckytah https://github.com/chuckytah Ugh, that was my mistake... I deleted the branch since I thought I had already merged in the changes; turns out I didn't.
I'll have to poke at this again later.
— Reply to this email directly or view it on GitHub https://github.com/oostendo/python-zxing/issues/6#issuecomment-172969617 .
@Manouchehri This is so far in the past I have no idea what I was even trying to do here or use this library for, I apologize.
I have the same issue, I put my python script in zxing/javase/python-zxing/ and didn't put any location when I initiate the BarCodeReader. Is there any solution for this?
I got it to work by changing the following lines in __init__.py
libs = ["javase/javase.jar", "core/core.jar"]
args = ["-cp", "LIBS", "com.google.zxing.client.j2se.CommandLineRunner"]
to
libs = ["javase/javase.jar"]
args = ["-jar", "LIBS"]
and then I ran mvn -DskipTests package assembly:single
in the javase/
directory.
Also @feliciaamy, BarCodeReader looks for the parent directory of javase/
, so you need to initiate BarCodeReader with the path to zxing/
.
Here are some instructions for zxing 3.3.2
- git clone ...
- mvn install
- copy core/target/coreXXX.jar -> ./core/core,jar
- copy javase/target/javaseXXX.jar -> javase/javase.jar
- Download JCommander (current 1.72 is okay) http://central.maven.org/maven2/com/beust/jcommander
- Modify init.py libs = ["javase.jar", "core.jar", "jcommander.jar"] no need to change args like this args = ["-jar", "LIBS"]
- cd python-zxing sudo pip3 install .
- Use only --try-harder (if needed) specifying code classes doesn't work
git clone https://github.com/zxing/zxing.git cd zxing-master mvn install cd core
go check for the latest version
wget http://central.maven.org/maven2/com/google/zxing/core/${version}/${version}.jar mv core-${version}.jar core.jar # Rename mvn install cd zxing-master/javase
go check for the latest version
wget http://central.maven.org/maven2/com/google/zxing/javase/${version}/javase-${version}.jar mv javase-${version}.jar javase.jar # Rename mvn install git clone git://github.com/oostendo/python-zxing.git
must install java 8, if not a lots of debugging for java 11/12
After building, in the javase/ directory, execute mvn -DskipTests package assembly:single to create a single JAR file containing all classes needed to run client command line apps, as target/javase-x.y.z-jar-with-dependencies.jar. Run CommandLineRunner with simply:
java -jar target/javase-x.y.z-jar-with-dependencies.jar [URL | FILE]
Eg: ['java', '-jar', './zxing-zxing-3.4.0/javase/target/javase-3.4.0-jar-with-dependencies.jar', '--try_harder', './samples/1.jpg']
modify
libs = ["javase/target/javase-3.4.0-jar-with-dependencies.jar"] args = ["-jar", "LIBS"]