IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Jar exécutable + JOGL


Sujet :

OpenGL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2008
    Messages : 18
    Par défaut [Résolu]Jar exécutable + JOGL
    Bonjour,

    J'ai codé un truc en JOGL et j'aimerai en faire un jar exécutable et portable au moins sous GNU/Linux, Mac OS et Windows. Je travaille avec Eclipse. Quand j'exporte le projet en jar exécutable, il ajoute bien les jar de jogl mais pas les librairies natives. J'ai essayé en les ajoutant moi-même dans le jar mais ça ne donne rien. Pourriez-vous m'aider?? Merci!

  2. #2
    Expert confirmé

    Profil pro
    Fabricant et casseur d'avions
    Inscrit en
    Avril 2004
    Messages
    3 819
    Détails du profil
    Informations personnelles :
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Fabricant et casseur d'avions
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Avril 2004
    Messages : 3 819
    Par défaut
    Salut

    Citation Envoyé par jafar456 Voir le message
    J'ai essayé en les ajoutant moi-même dans le jar mais ça ne donne rien.
    Ne les mets pas DANS le jar, mais à côté, dans le même répertoire. Normalement ça devrait être bon.
    "Errare humanum est, sed perseverare diabolicum"

    Ma page sur DVP.com

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2008
    Messages : 18
    Par défaut
    J'ai essayé mais ca ne va pas.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
    	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
    	at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    	at java.lang.System.loadLibrary(System.java:1030)
    	at com.sun.gluegen.runtime.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:102)
    	at com.sun.gluegen.runtime.NativeLibLoader.access$000(NativeLibLoader.java:51)
    	at com.sun.gluegen.runtime.NativeLibLoader$1.run(NativeLibLoader.java:70)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.gluegen.runtime.NativeLibLoader.loadGlueGenRT(NativeLibLoader.java:68)
    	at com.sun.gluegen.runtime.NativeLibrary.ensureNativeLibLoaded(NativeLibrary.java:399)
    	at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:163)
    	at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:129)
    	at com.sun.opengl.impl.x11.DRIHack.begin(DRIHack.java:109)
    	at com.sun.opengl.impl.x11.X11GLDrawableFactory.<clinit>(X11GLDrawableFactory.java:99)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:169)
    	at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:111)
    	at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520)
    	at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
    	at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
    	at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
    	at Launcher.run(Launcher.java:21)
    	at java.lang.Thread.run(Thread.java:619)

    Donc j'ai trouvé une autre méthode mais qui ne va pas non plus

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    // 1. Determine the OS we're running on and make a native library name
    		// from that.
    		String osName = System.getProperty("os.name"), nativeLibName1 = null, nativeLibName2 = null, nativeLibName3 = null, nativeLibName4 = null;
     
    		if (osName.equals("Windows")) {
    			nativeLibName1 = "jogl.dll";
    			nativeLibName2 = "gluegen-rt.dll";
    			nativeLibName3 = "jogl_cg.dll";
    			nativeLibName4 = "jogl_awt.dll";
    			System.out.println("Systeme Windows detecte.");
    		} else if (osName.equals("Linux")) {
    			nativeLibName1 = "libjogl.so";
    			nativeLibName2 = "libgluegen-rt.so";
    			nativeLibName3 = "libjogl_cg.so";
    			nativeLibName4 = "libjogl_awt.so";
    			System.out.println("Systeme GNU/Linux detecte.");
    		} else if (osName.equals("MacOS")) {
    			nativeLibName1 = "libjogl.jnilib";
    			nativeLibName2 = "libgluegen-rt.jnilib";
    			nativeLibName3 = "libjogl_cg.jnilib";
    			nativeLibName4 = "libjogl_awt.jnilib";
    			System.out.println("Systeme MacOS detecte.");
    		} else {
    			System.out.println("Votre systeme n'est pas supporte.");
    			System.exit(1);
    		}
     
    		try {
    			// 2. Write this library to a file. Windows: Documents and
    			// Settings\\username; Linux: /home/username
    			InputStream nativeLibIn1 = new FileInputStream(new File("libs/"
    					+ nativeLibName1));
    			InputStream nativeLibIn2 = new FileInputStream(new File("libs/"
    					+ nativeLibName2));
    			InputStream nativeLibIn3 = new FileInputStream(new File("libs/"
    					+ nativeLibName1));
    			InputStream nativeLibIn4 = new FileInputStream(new File("libs/"
    					+ nativeLibName2));
     
    			System.out.println(nativeLibName1);
    			System.out.println(nativeLibName2);
    			System.out.println(nativeLibName3);
    			System.out.println(nativeLibName4);
     
    			File nativeLib1 = new File(System.getProperty("user.home"),
    					nativeLibName1);
    			File nativeLib2 = new File(System.getProperty("user.home"),
    					nativeLibName2);
    			File nativeLib3 = new File(System.getProperty("user.home"),
    					nativeLibName1);
    			File nativeLib4 = new File(System.getProperty("user.home"),
    					nativeLibName2);
     
    			OutputStream nativeLibOut1 = new FileOutputStream(nativeLib1);
    			OutputStream nativeLibOut2 = new FileOutputStream(nativeLib2);
    			OutputStream nativeLibOut3 = new FileOutputStream(nativeLib3);
    			OutputStream nativeLibOut4 = new FileOutputStream(nativeLib4);
     
    			int readBytes1;
    			int readBytes2;
    			int readBytes3;
    			int readBytes4;
     
    			byte[] buffer1 = new byte[4096];
    			byte[] buffer2 = new byte[4096];
    			byte[] buffer3 = new byte[4096];
    			byte[] buffer4 = new byte[4096];
     
    			while ((readBytes1 = nativeLibIn1.read(buffer1)) > 0)
    				nativeLibOut1.write(buffer1, 0, readBytes1);
    			while ((readBytes2 = nativeLibIn2.read(buffer2)) > 0)
    				nativeLibOut2.write(buffer2, 0, readBytes2);
    			while ((readBytes3 = nativeLibIn3.read(buffer3)) > 0)
    				nativeLibOut3.write(buffer3, 0, readBytes3);
    			while ((readBytes4 = nativeLibIn4.read(buffer4)) > 0)
    				nativeLibOut4.write(buffer4, 0, readBytes4);
     
    			// 3. Load JOGL. System.load requires an absolute path.
    			System.load(nativeLib1.toString());
    			System.load(nativeLib2.toString());
    			System.load(nativeLib3.toString());
    			System.load(nativeLib4.toString());
     
    		} catch (IOException ioe) {
    			System.out.println("Erreur de chargement des libraires natives.\n");
    			ioe.printStackTrace();
    		}
    Avec ca, j'obtiens

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    jafar@Jlaptop:~/Bureau$ java -jar SG.jar 
    Systeme GNU/Linux detecte.
    libjogl.so
    libgluegen-rt.so
    libjogl_cg.so
    libjogl_awt.so
    Inconsistency detected by ld.so: ../sysdeps/x86_64/dl-machine.h: 458: elf_machine_rela_relative: Assertion `((reloc->r_info) & 0xffffffff) == 8' failed!

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2008
    Messages : 18
    Par défaut solution
    Finalement en les mettant dans un dossier connu ou en les mettant dans le même dossier comme le disait plegat, ça marche mais a condition de lancer le jar en console avec cet argument :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    java "-Djava.library.path=chemin_des_librairies" -jar programme.jar
    voilà

Discussions similaires

  1. [JAR] Export jar exécutable
    Par meli0207 dans le forum Eclipse Java
    Réponses: 8
    Dernier message: 15/06/2010, 15h19
  2. création javadoc + jar exécutable
    Par scoder dans le forum Langage
    Réponses: 7
    Dernier message: 04/11/2005, 17h06
  3. [débutante] [Applet] [jar exécutable]
    Par wwave dans le forum Applets
    Réponses: 9
    Dernier message: 15/09/2005, 14h31
  4. [JAR exécutable] comment y intégrer des librairies ?
    Par sixkiller dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 07/04/2005, 10h03
  5. [Jar]Faire un jar exécutable
    Par Melchisedec dans le forum Général Java
    Réponses: 2
    Dernier message: 09/06/2004, 18h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo