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

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

Open
g-amador opened this issue Apr 14, 2020 · 12 comments
Open

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

g-amador opened this issue Apr 14, 2020 · 12 comments

Comments

@g-amador
Copy link
Collaborator

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.

@Sylvyrfysh
Copy link
Collaborator

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!

@g-amador
Copy link
Collaborator Author

g-amador commented Apr 15, 2020

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 g-amador reopened this Apr 15, 2020
@Sylvyrfysh
Copy link
Collaborator

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,

@g-amador
Copy link
Collaborator Author

g-amador commented Apr 16, 2020

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
Copy link
Collaborator Author

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)

@elect86
Copy link
Collaborator

elect86 commented Nov 4, 2020

@g-amador you should use the jdk8 branch

@g-amador
Copy link
Collaborator Author

g-amador commented Nov 4, 2020

@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?

@elect86
Copy link
Collaborator

elect86 commented Nov 5, 2020

@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?

@g-amador
Copy link
Collaborator Author

g-amador commented Nov 5, 2020

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

@elect86
Copy link
Collaborator

elect86 commented Nov 6, 2020

pushed

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

@g-amador
Copy link
Collaborator Author

g-amador commented Nov 6, 2020

Hello,

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

Best regards

@elect86
Copy link
Collaborator

elect86 commented Nov 6, 2020

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>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants