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

Cannot load pcap4j-packetfactory-static on JavaFx project #220

Closed
spencerwooo opened this issue May 3, 2019 · 4 comments
Closed

Cannot load pcap4j-packetfactory-static on JavaFx project #220

spencerwooo opened this issue May 3, 2019 · 4 comments
Labels

Comments

@spencerwooo
Copy link

image

I'm running pcap4j with Java 12, on a JavaFX project using maven. I can run the project with javafx:run, but I can't load the pcap4j-packetfactory-static library. It seems that the module name static is a Java keyword and it can't be recognized during runtime. Is there something I'm doing wrong?

BTW, my pom.xml looks like this:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.pcap4j</groupId>
        <artifactId>pcap4j-core</artifactId>
        <version>2.0.0-alpha.3</version>
    </dependency>
    <dependency>
        <groupId>org.pcap4j</groupId>
        <artifactId>pcap4j-packetfactory-static</artifactId>
        <version>2.0.0-alpha.3</version>
    </dependency>
</dependencies>
@kaitoy
Copy link
Owner

kaitoy commented May 6, 2019

That error should be solved by PR #207 which was merged very recently.
I will release a version with the fix within 2 weeks.
In the meantime, you can try a snapshot version: https://oss.sonatype.org/content/repositories/snapshots/org/pcap4j/pcap4j/2.0.0-alpha.4-SNAPSHOT/pcap4j-2.0.0-alpha.4-20190430.080233-9-distribution.zip

@spencerwooo
Copy link
Author

Thank you so much @kaitoy , I'll be trying the snapshot version asap.

@spencerwooo
Copy link
Author

Totally solved the problem! The snapshot version works like a charm. 🍻

For those who are also trying to use the snapshot version, here're my configurations:

  • First modify your global maven repo settings in settings.xml, usually located at ~/.m2/settings.xml (Create a new one if you don't see it), then add <profiles> section in said file, like so:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
    ...
    <profiles>
        <profile>
            <id>allow-snapshots</id>
            <activation><activeByDefault>true</activeByDefault></activation>
            <repositories>
                <repository>
                    <id>snapshots-repo</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                    <releases><enabled>false</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
    ....
</settings>
  • Then in your project's pom.xml file, change pcap4j's version to:
<dependency>
    <groupId>org.pcap4j</groupId>
    <artifactId>pcap4j-core</artifactId>
    <version>2.0.0-alpha.4-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.pcap4j</groupId>
    <artifactId>pcap4j-packetfactory-static</artifactId>
    <version>2.0.0-alpha.4-SNAPSHOT</version>
</dependency>
  • Finally, run maven clean and maven install, and you're good to go.

@kaitoy
Copy link
Owner

kaitoy commented May 21, 2019

Pcap4J 1.8.0 and 2.0.0-alpha.4 are released with Java 9+ support that includes fixes for this issue.

@kaitoy kaitoy closed this as completed May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants