oostendo / python-zxing

python wrapper for the ZXing barcode library
http://code.google.com/p/zxing
272 stars 104 forks source link

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

Open BrandonCopley opened 10 years ago

BrandonCopley commented 10 years ago

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 commented 10 years ago

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

brianwanjir commented 9 years ago

Did you ever find a solution to this issue?

Manouchehri commented 9 years ago

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

BrandonCopley commented 9 years ago

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

Manouchehri commented 9 years ago

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?

brianwanjir commented 9 years ago

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 <notifications@github.com

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 .

Manouchehri commented 9 years ago

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

chuckytah commented 8 years ago

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?

ankita-kumari commented 8 years ago

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

Manouchehri commented 8 years ago

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

chuckytah commented 8 years ago

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" notifications@github.com 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 .

BrandonCopley commented 8 years ago

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

feliciaamy commented 7 years ago

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?

alanrgan commented 7 years ago

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

tsifra commented 6 years ago

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
wyichew2708 commented 4 years ago

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