Bonjour à tous,
j'ai une classe java swing que j'ai l'exporter en .jar, et je veux qu'elle soit exécuter dans une page JSP, j'ai essayer plusieurs méthode mais en vin,
alors je recours à vous pour m'aider à corriger ce problème, ma question est, comment je peux exécuter ce jar en JSP?
Voilà mon code de ma classe java:
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Calendar;
import java.util.Date;
 
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.category.IntervalCategoryDataset;
import org.jfree.data.gantt.Task;
import org.jfree.data.gantt.TaskSeries;
import org.jfree.data.gantt.TaskSeriesCollection;
import org.jfree.data.time.SimpleTimePeriod;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
 
 
public class First extends ApplicationFrame {
 
 
    public First(final String title) {
 
        super(title);
 
        final IntervalCategoryDataset dataset = createDataset();
        final JFreeChart chart = createChart(dataset);
 
        // add the chart to a panel...
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(1000, 500));
        setContentPane(chartPanel);
 
    }
 
    public static IntervalCategoryDataset createDataset() {
    	final TaskSeriesCollection collection = new TaskSeriesCollection();
    	final TaskSeries s1 = new TaskSeries("Scheduled");
    	Connection Con = null;
    	try
		{
			Class.forName("com.mysql.jdbc.Driver");
		}
			catch (ClassNotFoundException e)
		{
			System.out.println("Impossible de charger le pilote jdbc " +e);
		}
 
		//connection a la base de données
		System.out.println("Connection a la base de données");
		try
		{		
 
			Con = DriverManager.getConnection("jdbc:mysql://localhost:3307/bdreclam","root","1234");
		} 
		catch (SQLException e) 
		{
			System.out.println("Connection à la base de données impossible "+ e);
 
		}
		String requete="select * from affectation;";
		try
		{
		Statement stmt = Con.createStatement();
		ResultSet res = stmt.executeQuery(requete);
		while (res.next())
		{
			 String ch1=res.getString("Date_deb_des");
			 String ch2=res.getString("Date_fin_des");
			 int jj=Integer.parseInt(ch1.substring(0,2));
			 int mm=Integer.parseInt(ch1.substring(3,5));
			 int aa=Integer.parseInt(ch1.substring(6,10));
			 int j=Integer.parseInt(ch2.substring(0,2));
			 int m=Integer.parseInt(ch2.substring(3,5));
			 int a=Integer.parseInt(ch2.substring(6,10));
			 System.out.println(res.getString("mat_emp")+" : "+jj+"/"+mm+"/"+aa+" to "+j+"/"+m+"/"+a);
		        s1.add(new Task(res.getString("mat_emp")+" "+res.getString("idrec"),new SimpleTimePeriod(date(jj,mm-1,aa),date(j,m-1,a))));
		}
		collection.add(s1);	
		}
		catch (SQLException e) {
		e.printStackTrace();
		}
		return collection;
    }
 
    /**
     * Utility method for creating <code>Date</code> objects.
     *
     * @param day  the date.
     * @param month  the month.
     * @param year  the year.
     *
     * @return a date.
     */
    private static Date date(final int day, final int month, final int year) {
 
        final Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day);
        final Date result = calendar.getTime();
        return result;
 
    }
 
    /**
     * Creates a chart.
     * 
     * @param dataset  the dataset.
     * 
     * @return The chart.
     */
    private JFreeChart createChart(final IntervalCategoryDataset dataset) {
        final JFreeChart chart = ChartFactory.createGanttChart(
            "Tâches Des Informaticiens",  // chart title
            "Tâche",              // domain axis label
            "Date",              // range axis label
            dataset,             // data
            true,                // include legend
            true,                // tooltips
            true                // urls
        );    
//        chart.getCategoryPlot().getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
        return chart;    
    }
 
    /**
     * Starting point for the demonstration application.
     *
     * @param args  ignored.
     */
    public static void main(final String[] args) {
 
        final First demo = new First("Disponibilité Des Informaticiens");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);
 
    }
 
}
Merci d'avance.