G
G
g9052020-03-18 22:06:32
Java
g905, 2020-03-18 22:06:32

How to add a package to a project?

Hello. The second evening I'm stupid with maven. I ask the audience for help.

I'm trying to add dependencies to a project.
I add everything to pom.xml as written (in general, I want to add this , but it doesn’t matter)
Here is pom.xml:

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>ru.g905</groupId>
    <artifactId>gl</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <lwjgl.version>3.2.3</lwjgl.version>
        <lwjgl.natives>natives-linux</lwjgl.natives>
        <natives.version>0.0.6</natives.version>
        <platform>linux</platform>
    </properties>
   
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
 
            <plugin>
                <groupId>com.googlecode.mavennatives</groupId>
                <artifactId>maven-nativedependencies-plugin</artifactId>
                <version>${natives.version}</version>
                <executions>
                    <execution>
                        <id>unpacknatives</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <!--suppress MavenModelInspection (this line is for IDEA)-->
                            <goal>copy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>ru.g905.gl.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.lwjgl</groupId>
                <artifactId>lwjgl-bom</artifactId>
                <version>${lwjgl.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-vulkan</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-par</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-bgfx</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-cuda</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-shaderc</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-vma</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-par</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-bgfx</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-vma</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-shaderc</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>natives-${platform}</classifier>
        </dependency>
    </dependencies>
</project>



I click "Build (Clean and build or Build with dependencies)", maven downloads whatever it wants. Says "Build successful".

Question: How now to make it so that the project uses all these supposedly installed dependencies?
I write: System.out.println(org.lwjgl.Version); NetBeans insists on underlining "org" in red and saying that the org package doesn't exist. And at the same time, it cynically gives hints about which packages can be added from the org.

Screen

BgYmBrd.png


Tried downloading the zip manually. Still does not see.
I tried to move the downloaded packages to the org folder, next to ru. Did not help.
Where to place what, where can I cast the "org" package?
And how should maven work in general? - Do I need to download something manually after adding everything to pom.xml and collecting it? Before I started all this, it seemed to me that no.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacen11, 2020-03-18
@g905

It's rare, but you've screwed up a hell of a lot of times.
To begin with, demolish the eclipse and put the idea, this is not your level.
Secondly, the pomnik is correct, everything is immediately picked up as it should. Maven just downloads and connects libs. In general, it is better to use Gradle, if there are no special requirements.

Question: How now to make it so that the project uses all these supposedly installed dependencies?

They are already in use
Tried downloading the zip manually. Still does not see.

in general, it’s also possible, as in eclipse I won’t say for sure
I tried to transfer the downloaded packages to the org folder, next to ru. Did not help.

What for? What do you think should have happened? Do you even understand why the separation of packages?
Where to place what, where can I cast the "org" package?

what does that even mean? you don't have to place or cast anything anywhere
I write: System.out.println(org.lwjgl.Version);

Do you even understand what you write? Not only do you not create an object, but the constructor is also private there. What are you going to print there?
By the way, what does a normal ide write
5e7288037e165864985424.png
? Maybe you wanted this? But then you just don't understand what you're doing.
5e728839f338c018110353.png
With maven and import, everything is in order, you just got a little hacked and trying to do not understand what from any point of view (both language and logic).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question