1

I wanted to show the barcode in primefcaes.For that i created a maven based project & added two dependency for those libararies such as

<dependency>
    <groupId>net.glxn</groupId>
    <artifactId>qrgen</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>net.sf.barcode4j</groupId>
    <artifactId>barcode4j-light</artifactId>
    <version>2.1</version>
</dependency>

I read in primefaces documentation that barcode4j-2.1 may not be available in maven so i need to manual install the jar in maven repo

I have installed the jar into maven repo using this command in eclipse

install:install-file -Dfile=D:\qrgen-1.4.jar -DgroupId=net.glxn -DartifactId=qrgen -Dversion=1.4 -Dpackaging=jar

 install:install-file -Dfile=D:\barcode4j-light-2.1.jar -DgroupId=net.sf.barcode4j -DartifactId=barcode4j-light -Dversion=2.1 -Dpackaging=jar

POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.prime</groupId>
    <artifactId>primedemop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>primefaces</name>
    <dependencies>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>net.glxn</groupId>
            <artifactId>qrgen</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>net.sf.barcode4j</groupId>
            <artifactId>barcode4j-light</artifactId>
            <version>2.1</version>
        </dependency>
    </dependencies>
</project>

But i can't see any barcode generated if i was adding the barcode4j-light-2.1 jar file in lib folder then i was able to generate bar code but not the QR code but now i can't generate not even barcode.

I get the following output on eclipse console when i install the jar file into maven repo.

For qrgen jar

pic1 for barcode4j pic2

Ankit Sharma
  • 147
  • 1
  • 9

1 Answers1

2

Look at the groupId and artifactId's for your dependencies and what you installed:

qrgen:       -DgroupId=net.glxn.qrgen -DartifactId=qrgen
qrgen-light: -DgroupId=net.glxn.qrgen -DartifactId=qrgen

Your dependencies show a different group/artifactId:

<dependency>
    <groupId>net.glxn</groupId>                 <--- here
    <artifactId>qrgen</artifactId>              <--- here
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>net.sf.barcode4j</groupId>         <--- here
    <artifactId>barcode4j-light</artifactId>    <--- here
    <version>2.1</version>
</dependency>

You manually installed your jars to a directory in the maven repo called net/glxn/qrgen/qrgen but your dependencies are expecting to find them in net/glxn/qrgen and net/sf/barcode4j/barcode4j-light respectively.

You need to update your manual install commands to:

install:install-file -Dfile=D:\qrgen-1.4.jar -DgroupId=net.glxn -DartifactId=qrgen -Dversion=1.4 -Dpackaging=jar

and

install:install-file -Dfile=D:\barcode4j-light-2.1.jar -DgroupId=net.sf.barcode4j -DartifactId=barcode4j-light -Dversion=1.4 -Dpackaging=jar
Ryan J
  • 8,275
  • 3
  • 25
  • 28
  • I did the same as you suggested.Now i am able to generate the barcode but not able to get the qr code?@Ryan J – Ankit Sharma May 01 '15 at 19:55
  • I did the same as you suggested.Now i am able to generate the barcode but not able to get the qr code?@Ryan J' – Ankit Sharma May 01 '15 at 19:55
  • @AnkitSharma can you update your question with the commands you used and your POM file? Can you display somehow that the dependencies are being properly resolved, to eliminate some other non-Maven related issue? – Ryan J May 01 '15 at 19:57
  • @AnkitSharma looks like you still have an incorrect groupId for the qrcode lib. `-DgroupId=net.glxn.qrgen` should be `-DgroupId=net.glxn` – Ryan J May 01 '15 at 21:32
  • I am sorry i updated wrong code on stack overflow but in actual i am using the way as you suggested.Please now check the install command & dependency.I am still not able to print the qr code.Please help me out.i have been having hard time figuring it out. @Ryan J – Ankit Sharma May 02 '15 at 14:52
  • Please tell me the way out? – Ankit Sharma May 02 '15 at 18:21
  • @AnkitSharma Are you able to compile your code using imports for the `net.glxn.*` packages? if so, then Maven is working properly, it's something else in your code that's not working. Maven is a dependency manager, so if the functionality you're expecting isn't there, but the libraries are, then something else is wrong. – Ryan J May 02 '15 at 19:01
  • Yeah i added the dependency.I am able to generate the barcodes of like barcode,linecode,upc,data matrix & so on.But the only problem is with the QR codes.I am not able to generate it.I have tried so many ways.Please help me I have been sturggling for three days now. @Ryan J – Ankit Sharma May 02 '15 at 19:06
  • @AnkitSharma The root of your question was about Maven dependencies. Sounds to me like the dependency issue is resolved, and you have some other problem with your implementation. My suggestion would be to mark this question resolved and open up a new question and post your source code and why you're not seeing what you expect. – Ryan J May 02 '15 at 19:10
  • http://stackoverflow.com/questions/29976277/primefaces-qr-code-not-shown/ here i have already asked this question but not getting any good solution.I was told to use maven for this.I used maven & i came with this issue which is kindda resolved but output is not getting @Ryan J – Ankit Sharma May 02 '15 at 19:16
  • Can you provide me the solution? @Ryan J – Ankit Sharma May 02 '15 at 19:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76805/discussion-between-ankit-sharma-and-ryan-j). – Ankit Sharma May 03 '15 at 13:00