dsiddharth2 / php-zxing

PHP wrapper for Zxing Java library
MIT License
126 stars 25 forks source link

Is the java PATH set correctly ? Current Path set is : C:\Program Files\Java\jdk-14.0.2 #23

Open Aldana1985 opened 4 years ago

Aldana1985 commented 4 years ago

Hi! I keep getting the same message: Is the java PATH set correctly ? Current Path set is : C:\Program Files\Java\jdk-14.0.2 I know my path and it's well written but still doesn't recognize it. Also I don't know where to install this: {
"require": { "dsiddharth2/php-zxing": "1.0.3" }
}

If you can help me I'd aprecciated. Thanks.

SuperFred commented 3 years ago

You need to set the path with the java.exe and add doublequote

this work for me : $decoder->setJavaPath('"C:/Program Files/Java/jdk-11.0.6/bin/java.exe"');

gouyuwang commented 3 years ago

@SuperFred is right.

in addition:

//==> This is a bug $img_path = str_replace('\', '/', $img_path); $decoder->decode("file:///" . $img_path);

lintangtimur commented 3 years ago

You need to set the path with the java.exe and add doublequote

this work for me : $decoder->setJavaPath('"C:/Program Files/Java/jdk-11.0.6/bin/java.exe"');

not work for me, message still appear

SuperFred commented 3 years ago

@lintangtimur be sure the path to your java.exe is correct

In Windows at the command prompt

where java

endcycles commented 3 years ago

I can run the Jar files directly from my SSH command line.

java -cp javase-3.3.3.jar:core-3.3.3.jar:jcommander-1.72.jar com.google.zxing.client.j2se.CommandLineRunner ../../../../../images/testimage.jpg
file:///home/earnrnet/public_html/barcode/vendor/dsiddharth2/php-zxing/src/bin/../../../../../images/testimage.jpg (format: PDF_417, type: TEXT):
Raw result:
6200868213185368
Parsed result:
6200868213185368
Found 8 result points.
  Point 2: (599.0,673.0)
  Point 3: (599.0,754.0)
  Point 6: (534.0,673.0)
  Point 7: (534.0,754.0)

This is my response when I run the PHP file: Is the java PATH set correctly ? Current Path set is : /home/earnrnet/java/jdk-17.0.1/bin/java"

This is my Java version:

java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

PATH has been setup and I can use java command within my SSH console.

which java command returns:

~/java/jdk-17.0.1/bin/java

readlink -f returns

/home/earnrnet/java/jdk-17.0.1/bin/java

I have tried the$realJavaPath = exec('readlink -f [FILEPATH]'); with no luck.

I also attempted to edit PHPZxingDecoder.php basePrepare() method from $this->getJavaPath() to java and it still won't work, throwing the same exact error.