python-zxing icon indicating copy to clipboard operation
python-zxing copied to clipboard

Could not find or load main class com.google.zxing.client.j2se.CommandLineRunner

Open BrandonCopley opened this issue 10 years ago • 16 comments

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)

BrandonCopley avatar May 13 '14 18:05 BrandonCopley

It appears I just don't know that much about java - I need to find where zxing got installed.

BrandonCopley avatar May 13 '14 18:05 BrandonCopley

Did you ever find a solution to this issue?

brianwanjir avatar Aug 07 '15 10:08 brianwanjir

@BrandonCopley: Were you running python-zxing on Windows or Linux?

Manouchehri avatar Aug 09 '15 01:08 Manouchehri

I am running this on Mac (Unix). However, it's been a long time since I've looked into this.

BrandonCopley avatar Aug 10 '15 15:08 BrandonCopley

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?

Manouchehri avatar Aug 12 '15 12:08 Manouchehri

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 .

brianwanjir avatar Aug 12 '15 12:08 brianwanjir

@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.

Manouchehri avatar Aug 12 '15 16:08 Manouchehri

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?

chuckytah avatar Dec 03 '15 17:12 chuckytah

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. :)

ankita-kumari avatar Jan 19 '16 19:01 ankita-kumari

@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.

Manouchehri avatar Jan 19 '16 20:01 Manouchehri

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 .

chuckytah avatar Jan 20 '16 08:01 chuckytah

@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.

BrandonCopley avatar Feb 22 '16 21:02 BrandonCopley

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?

feliciaamy avatar Mar 15 '17 03:03 feliciaamy

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/.

alanrgan avatar Jun 01 '17 19:06 alanrgan

Here are some instructions for zxing 3.3.2

  1. git clone ...
  2. mvn install
  3. copy core/target/coreXXX.jar -> ./core/core,jar
  4. copy javase/target/javaseXXX.jar -> javase/javase.jar
  5. Download JCommander (current 1.72 is okay) http://central.maven.org/maven2/com/beust/jcommander
  6. Modify init.py libs = ["javase.jar", "core.jar", "jcommander.jar"] no need to change args like this args = ["-jar", "LIBS"]
  7. cd python-zxing sudo pip3 install .
  8. Use only --try-harder (if needed) specifying code classes doesn't work

tsifra avatar Jan 08 '18 19:01 tsifra

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"]

pass in zxing as main root

wyichew2708 avatar Oct 16 '19 07:10 wyichew2708