bonjour,
je suis débutant avec maven et j'ai un petit problème avec maven; j'ai créé d'abord un projet à partir d'eclipse, un projet maven.
j'ai ajouté une JFRAME swing dans ce projet et ai défini la classe à lancer.
un petit "maven install" et j'ai pu obtenir ma fenêtre via un "java -jar monappli.jar".
ensuite, et parce que j'aime bien le gestionnaire de look-and-feel "substance", j'ai essayé de l'inclure dans mon projet, le projet étant disponible sur le repo central de maven.
et là, impossible de lancer le jar.
pourtant j'ai un "build successfull" lorsque je lance "maven install" à partir d'eclipse.
enfin, j'avais, car j'ai fait quelques modifs depuis et maintenant àa ne marche plus.
voici quelques bouts de code:
pom.xml
extrait de ma JFRAME
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 <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>olivier_maison</groupId> <artifactId>test_swing_1_swing</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>test_swing_1_swing</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.java.net.substance</groupId> <artifactId>substance</artifactId> <version>6.0</version> <type>jar</type> <scope>runtime</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>frames.fenetre_hello_world</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptors> <descriptor>src/assembly/dist.xml</descriptor> </descriptors> </configuration> </plugin> </plugins> </build> </project>
dist.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); EventQueue.invokeLater(new Runnable() { public void run() { try { fenetre_hello_world frame = new fenetre_hello_world(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } });
(ça j'ai pas trop compris).
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 <assembly> <id>dist</id> <formats> <format>dir</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>target</directory> <outputDirectory></outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> </fileSets> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> <unpack>false</unpack> <scope>runtime</scope> </dependencySet> </dependencySets> </assembly>
l'erreur sous eclipse, avec le code précédent:
l'erreur lorsque je lance "java -jar monjar.jar":
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 [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for olivier_maison:test_swing_1_swing:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 35, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building test_swing_1_swing 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ test_swing_1_swing --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test_swing_1_swing --- [INFO] Compiling 2 source files to /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[12,38] package org.pushingpixels.substance.api does not exist [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[13,43] package org.pushingpixels.substance.api.skin does not exist [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,35] cannot find symbol symbol : class BusinessBlackSteelSkin location: class frames.fenetre_hello_world [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,2] cannot find symbol symbol : variable SubstanceLookAndFeel location: class frames.fenetre_hello_world [INFO] 4 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.324s [INFO] Finished at: Sun Jun 05 03:04:30 CEST 2011 [INFO] Final Memory: 7M/82M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project test_swing_1_swing: Compilation failure: Compilation failure: [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[12,38] package org.pushingpixels.substance.api does not exist [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[13,43] package org.pushingpixels.substance.api.skin does not exist [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,35] cannot find symbol [ERROR] symbol : class BusinessBlackSteelSkin [ERROR] location: class frames.fenetre_hello_world [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,2] cannot find symbol [ERROR] symbol : variable SubstanceLookAndFeel [ERROR] location: class frames.fenetre_hello_world [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 [olivier@fedora target]$ java -jar test_swing_1_swing-0.0.1-SNAPSHOT.jar Exception in thread "main" java.lang.NoClassDefFoundError: org/pushingpixels/substance/api/SubstanceSkin Caused by: java.lang.ClassNotFoundException: org.pushingpixels.substance.api.SubstanceSkin at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: frames.fenetre_hello_world. Program will exit. [olivier@fedora target]$ java -jar test_swing_1_swing-0.0.1-SNAPSHOT.jar Unable to access jarfile test_swing_1_swing-0.0.1-SNAPSHOT.jar
un coup de main serait grandement apprécié!
olivier
Partager