This discussion is archived
2 Replies Latest reply: Apr 11, 2012 5:07 PM by EJP RSS

linux

929873 Newbie
Currently Being Moderated
i made a application with help of jfreechart api. it run well on windows environment but not in linux(redhat). its not show the chart. it return null. no any frame work returne. i check it and found that the following code not work properly on linux but work same code on window 7.this ChartFrame frame1 = new ChartFrame("XYLine Chart", chart);
code
not
work
in follwing code
< %--
Document : chart12
Created on : Apr 9, 2012, 2:10:46 PM
Author : Vijay
--%>

<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>

<%@page import="org.jfree.chart.ChartFrame"%>
<%@page import="org.jfree.chart.plot.PlotOrientation"%>
<%@page import="org.jfree.chart.JFreeChart"%>
<%@page import="org.jfree.chart.ChartFactory"%>
<%@page import="org.jfree.data.XYSeriesCollection"%>
<%@page import="org.jfree.data.XYDataset"%>
<%@page import="org.jfree.data.XYSeries"%>



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
Connection con = null;
Statement st = null;
ResultSet rs = null;
String from_time = request.getParameter("f_time");
String to_time = request.getParameter("t_time");
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","root", "pass");
st = con.createStatement();
rs = st.executeQuery("select Time,Temp from tempdetail where time between '" + from_time + "' and '" + to_time + "'");
XYSeries series = new XYSeries("Average Temperature");
while (rs.next()) {
series.add(rs.getDouble(1), rs.getDouble(2));
}


XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart("IMD MONITORING SYSTEMChart", "Time", "Temp", xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame1 = new ChartFrame("XYLine Chart", chart);
frame1.setVisible(true);
frame1.setSize(1400,800);
response.sendRedirect( "chart.jsp"); //name of next page where which you want to call.
} catch (Exception e) {
out.println(e.getMessage());
// TODO: handle exception
}

%>
</body>
</html>
  • 1. Re: linux
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    926870 wrote:
    i check it and found that the following code not work properly on linux but work same code on window 7
    Then it should be easy to demonstrate that by writing a java class that shows exactly that. And without the JDBC code.

    Once you have determined that that class works on one OS and not the other then you can post that along with the version of OS for each platform.
  • 2. Re: linux
    EJP Guru
    Currently Being Moderated
    it return null ... ChartFrame frame1 = new ChartFrame("XYLine Chart", chart); code not work in following code
    You mean that line of code returns null? Because it doesn't. Your question remains unclear. I also don't understand why you want to construct Swing-based GUI displays in a server. They won't get to the client you know.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points