Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BrandonCopley opened this issue May 13, 2014 · 16 comments

Comments

@BrandonCopley
Copy link

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
Copy link
Author

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

@brianwanjir
Copy link

Did you ever find a solution to this issue?

@Manouchehri
Copy link
Contributor

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

@BrandonCopley
Copy link
Author

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

@Manouchehri
Copy link
Contributor

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
Copy link

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
#6 (comment)
.

@Manouchehri
Copy link
Contributor

@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
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link

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
#6 (comment)
.

@BrandonCopley
Copy link
Author

@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
Copy link

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
Copy link

alanrgan commented Jun 1, 2017

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
Copy link

tsifra commented Jan 8, 2018

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants