File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes how to create chart using java api Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "how to create chart using java api" Watch "how to create chart using java api" New topic
Author

how to create chart using java api

gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
hi friends, I want to retrieve some data from mysql db and want to show them in pie chart using java API. Is it possible? please give me some ideas how can I achieve this task using java api. thanks in advance....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Libraries like JFreeChart or JChart2D can do this. If this is part of a web app, check out cewolf, which is a JSP tag library on top of JFreeChart.


Ping & DNS - my free Android networking tools app
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
hi dittmer, thank you so much for your response. Definitely I will follow your instructions.
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
is it possible to create a chart using jsp? scenario: 1. I want to retrieve data from mysql db using jav api. 2. I want to show them using chart. I don't want to make this task more complex to using 3 party packages. I would like to do this with inbuild java api. please help me...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Why does it make a difference whether you learn an API built into the JRE, or a 3rd party API? But regardless, the JRE has no charting API built in, so unless you want to roll your own -which I recommend against- you have to use a 3rd party solution. And I still recommend to check out cewolf if you haven't done so yet - download the example web app, deploy it, and see what it can do for you. Or you can use Google Charts if you would rather have a JavaScript solution than a Java solution.
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
thank you so much for your last explanation. Basically I'm a unit tester, I have to automate that scenario but I struggled for a week to innovate this task. now I get some ideas. please answer my last question. can i use javaScript to perform my scenario? which I queried in my first post.If YES, please tell me the way to achieve or I should concentrate. Regards, santhosh.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

san thosh wrote:can i use javaScript to perform my scenario? which I queried in my first post.

You did not say anything at all about JavaScript in your first post. You asked about a Java API.

If you want to use a JavaScript solution, Ulf already gave you one resource. HighCharts is another.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
thanks bibeault. actually I'm planning to integrate(insert) js into jsp to achieve my task. I believe it will be succeed. I will update the status sooner. Regards, santhosh.
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
I have facing the following error while compile my java code: TestServlet.java:28:error:unreported exception class not found exception; must be caught or declare be thrown Class.for name("com.mysql.jdbc.Driver");. as per my understanding the java runtime could not find the mysql-connxxx.jar file to load.the following steps i have tried: I haven't use any ide to develop a .java file instead I used notepad and dropped the jfreechart.jar and jcommon.jar,also msql-connect-bin.jar files into tomcathome/lib folder. In command line navigate to my java file I have set my path=jdk location, and set class path=location of servlet-api.jar,jfreechart.jar, jcommon,mysqlconn-bin.jar(from tomcathome/lib dir),and executed javac TestServlet.java command in dos-command, and it throws filenotfoundexception. please let me know where I need to place mysql-conn-bin.jar to recognize java in runtime. please let me know I have missed anything in my steps. thanks in advance...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
I have facing the following error while compile my java code: TestServlet.java:28:error:unreported exception class not found exception; must be caught or declare be thrown Class.for name("com.mysql.jdbc.Driver");. as per my understanding the java runtime could not find the mysql-connxxx.jar file to load.

No, the problem is something entirely different. You need to read up on exception handling in Java - if a method can throw an exception, then the code either needs to catch that exception, or the surrounding method needs to declare that it throws that exception. In this case you probably want to catch the exception, and exit the code if it happens, because presumably the code won't get anything done if it can't access the DB for any reason (including a missing JDBC driver).
gow tham
Greenhorn

Joined: Sep 29, 2013
Posts: 29
so, the problem with catching exception? not in steps. please let me know my steps are correct which I posted in my last comments.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
The second exception you mention indicates that there was a problem, but it's impossible to say whether what you did would work or not without knowing exactly what you did.

Irrespective of that, I generally advise against using the CLASSPATH variable; either using the javac "-cp" option, or using a build tool like Ant are better options IMO.
 
Consider Paul's rocket mass heater.
 
subject: how to create chart using java api
 
Similar Threads
how to display bar chart based on the database values using jsp
Chart APIs
Writing image into WAR?
create chart application in java
creating a bar chart by taking values from database