assimp icon indicating copy to clipboard operation
assimp copied to clipboard

How do I setup this in a Java project in Netbeans?

Open g-amador opened this issue 5 years ago • 12 comments

Hi, I'm unfamiliar with kotlin.

So I download the project into my Linux Mint and then what? I assume that this can be used to generate a Jar that I'll include in my project. But how. Alternatively, via a Maven project.

g-amador avatar Apr 14 '20 05:04 g-amador

Glad to see you giving it a shot! Including this in a maven project is as easy as selecting the Maven tab on this page: https://jitpack.io/#kotlin-graphics/assimp/4.0-beta16 , otherwise, the assimp-all.jar from this page will work the same: https://github.com/kotlin-graphics/assimp/releases . Let me know if you need anything else!

Sylvyrfysh avatar Apr 14 '20 05:04 Sylvyrfysh

Hi,

1-Create a Maven Java application in Netbeans 8.2 2-Modified the pom.xml as follows

<?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>maven</groupId>
    <artifactId>AssimpMaven</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>com.github.kotlin-graphics</groupId>
            <artifactId>assimp</artifactId>
            <version>4.0-beta16</version>
        </dependency>
    </dependencies>
    <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>
    </properties>
</project>

3 - Modified the settings.xml as follows

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository>${user.home}/.m2/repository</localRepository>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <name>Central Repository</name>
                <url>https://repo.maven.apache.org/maven2</url>
                <layout>default</layout>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <updatePolicy>never</updatePolicy>
                </releases>
            </pluginRepository>
        </pluginRepositories>
        <profiles>
            <profile>
                    <id>development</id>
                    <activation>
                            <activeByDefault>true</activeByDefault>
                    </activation>
                    <properties>
                    </properties>
                    <repositories>
                        <repository>
                            <id>central</id>
                            <name>Central Repository</name>
                            <url>https://repo.maven.apache.org/maven2</url>
                            <layout>default</layout>
                            <snapshots>
                                <enabled>false</enabled>
                            </snapshots>
                        </repository>
                        <repository>
                            <id>jitpack.io</id>
                            <url>https://jitpack.io</url>
                        </repository>
                    </repositories>	
            </profile>
	</profiles>
</settings>

4 - Added a .java in the source files

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package maven.assimpmaven;

/**
 *
 * @author gpaiva
 */
public class Assimp {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
         //AiScene scene;// = new Importer().readFile("../assets_mini/dae/cow/cow.dae");
    }
    
}

5 - I cannot compile when I uncomment the //AiScene scene; missing some import or something else?

g-amador avatar Apr 15 '20 00:04 g-amador

I've never seen the repository block be added in the settings.xml, it's usually added in the pom.xml when I've seen it. I would recommend first copying the reposiyoties block from JitPack/Maven directly into your pom.xml and see if that fixes it. After that, the AIScene class should be in the assimp package, so you will also need to add in import assimp.* in your code. Otherwise, everything looks correct,

Sylvyrfysh avatar Apr 15 '20 01:04 Sylvyrfysh

Hi,

Modified the POM.xml and the Settings.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>maven</groupId>
    <artifactId>AssimpMaven</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>	
    <dependencies>
        <dependency>
            <groupId>com.github.kotlin-graphics</groupId>
            <artifactId>assimp</artifactId>
            <version>4.0-beta16</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <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>
    </properties>
</project>

settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository>${user.home}/.m2/repository</localRepository>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <name>Central Repository</name>
                <url>https://repo.maven.apache.org/maven2</url>
                <layout>default</layout>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <updatePolicy>never</updatePolicy>
                </releases>
            </pluginRepository>
        </pluginRepositories>
        <profiles>
            <profile>
                    <id>development</id>
                    <activation>
                            <activeByDefault>true</activeByDefault>
                    </activation>
                    <properties>
                    </properties>
                    <repositories>
                        <repository>
                            <id>central</id>
                            <name>Central Repository</name>
                            <url>https://repo.maven.apache.org/maven2</url>
                            <layout>default</layout>
                            <snapshots>
                                <enabled>false</enabled>
                            </snapshots>
                        </repository>
                    </repositories>	
            </profile>
	</profiles>
</settings>

Added import to assimp.* the main.java in the source files

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package maven.assimpmaven;

import assimp.*;

/**
 *
 * @author gpaiva
 */
public class Assimp {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        AiScene scene;// = new Importer().readFile("../assets_mini/dae/cow/cow.dae");
    }
    
}

when compiling I get:

COMPILATION ERROR : 
-------------------------------------------------------------
maven/assimp/Assimp.java:[22,9] error: cannot access AiScene
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.907s
Finished at: Thu Apr 16 01:21:16 WEST 2020
Final Memory: 14M/109M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project AssimpMaven: Compilation failure
maven/assimp/Assimp.java:[22,9] error: cannot access AiScene
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

g-amador avatar Apr 16 '20 00:04 g-amador

If I tried to create a Java Application and add the Jar as library I get the following error:

Compiling 1 source file to /home/gpaiva/Desktop/projects/code/modelos/Assimp/build/classes
Running javac...
/home/gpaiva/Desktop/projects/code/modelos/Assimp/src/assimp/Assimp.java:22: error: cannot access AiScene
         AiScene scene;// = new Importer().readFile("../assets_mini/dae/cow/cow.dae");
  bad class file: /home/gpaiva/Desktop/projects/code/modelos/Assimp/lib/assimp-all.jar(assimp/AiScene.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
1 error
/home/gpaiva/Desktop/projects/code/modelos/Assimp/nbproject/build-impl.xml:959: The following error occurred while executing this line:
/home/gpaiva/Desktop/projects/code/modelos/Assimp/nbproject/build-impl.xml:298: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

g-amador avatar Apr 16 '20 00:04 g-amador

@g-amador you should use the jdk8 branch

elect86 avatar Nov 04 '20 11:11 elect86

@elect86 tank for the feedback ... however how do I use the JDK8 branch of Assimp? Unsure how.

In NetBeans I'm using branch 8.2 of the Java SDK in the project settings. My doubt remains what must I change and in which of the *.xml files?

Alternatively what must I do to (steps in Oracle NetBeans not Apache) in order to use assimp with the JDK8?

g-amador avatar Nov 04 '20 16:11 g-amador

@elect86 tank for the feedback ... however how do I use the JDK8 branch of Assimp? Unsure how.

Uh sorry, assimp was still one of the last to not have that. All other libs as a -jdk8 branch I'll push that one in a moment

In the meanwhile, do you use Gradle or Maven?

elect86 avatar Nov 05 '20 14:11 elect86

Maven

If possible I'll only need what to put to in either *.xml Afterwards I would like to add or provide a quick setup if you want to add to wiki of this project. Additionally, my intent is to add this project as another module to my JOT project.

Best regards

g-amador avatar Nov 05 '20 17:11 g-amador

pushed

I'm all open for contributions, I'll send you an invite right away

elect86 avatar Nov 06 '20 10:11 elect86

Hello,

Don't I need to change anything in pom.xml ?

Best regards

g-amador avatar Nov 06 '20 11:11 g-amador

I'm not familiar with Maven, but looking here just add the repo:

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

and the dependency

<dependency>
    <groupId>com.github.kotlin-graphics</groupId>
    <artifactId>assimp</artifactId>
    <version>347ec4ea8e</version>
</dependency>

Let's point directly the commit for the moment (but you may even <version>jdk8-SNAPSHOT</version>)

elect86 avatar Nov 06 '20 14:11 elect86