JFreeChart import error - java

Anyone can tell me where can I find the full version of JFreeChart? I downloaded the JCommon and JFreeChart as well (from the sourceforge page), but the JFreeChart contains only the jfreechart-demo.jar, so even if I correctly added the libraries in Eclipse, it doesn't work either...
Many Thanks!

When unpacked, the required JAR files are in the lib directory.
$ ls -ln lib
total 5800
-rw-r--r--# 1 501 20 45024 Jul 31 2014 hamcrest-core-1.3.jar
-rw-r--r--# 1 501 20 330246 Jul 31 2014 jcommon-1.0.23.jar
-rw-r--r--# 1 501 20 13796 Jul 31 2014 jfreechart-1.0.19-experimental.jar
-rw-r--r--# 1 501 20 79793 Jul 31 2014 jfreechart-1.0.19-swt.jar
-rw-r--r--# 1 501 20 1570157 Jul 31 2014 jfreechart-1.0.19.jar
-rw-r--r--# 1 501 20 50769 Jul 31 2014 jfreesvg-2.0.jar
-rw-r--r--# 1 501 20 245039 Jul 31 2014 junit-4.11.jar
-rw-r--r--# 1 501 20 445025 Jul 31 2014 orsoncharts-1.4-eval-nofx.jar
-rw-r--r--# 1 501 20 72444 Jul 31 2014 orsonpdf-1.6-eval.jar
-rw-r--r--# 1 501 20 80054 Jul 31 2014 servlet.jar
-rw-r--r--# 1 501 20 17492 Jul 31 2014 swtgraphics2d.jar
For example, the following command line runs TimeSeriesChartDemo1 on Unix; separate class path entries with a semicolon (;) on Windows.
$ java -cp .:lib/* org.jfree.chart.demo.TimeSeriesChartDemo1

Related

Java binary available, but still "No such file or directory"

When I run the command I got the error:
root#1290ff36814b:/opt/airflow/dags# python test.py
/opt/spark-3.3.1/bin/spark-class: line 71: /opt/jdk1.8.0/bin/java: No such file or directory
/opt/spark-3.3.1/bin/spark-class: line 96: CMD: bad array subscript
Traceback (most recent call last):
File "test.py", line 16, in <module>
.appName('test') \
File "/opt/spark-3.3.1/python/pyspark/sql/session.py", line 269, in getOrCreate
sc = SparkContext.getOrCreate(sparkConf)
File "/opt/spark-3.3.1/python/pyspark/context.py", line 483, in getOrCreate
SparkContext(conf=conf or SparkConf())
File "/opt/spark-3.3.1/python/pyspark/context.py", line 195, in __init__
SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
File "/opt/spark-3.3.1/python/pyspark/context.py", line 417, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "/opt/spark-3.3.1/python/pyspark/java_gateway.py", line 106, in launch_gateway
raise RuntimeError("Java gateway process exited before sending its port number")
RuntimeError: Java gateway process exited before sending its port number
This is a docker container and /opt/jdk1.8.0 is a volume, and the volume is visible inside container and also de java binary.
root#1290ff36814b:/opt/airflow/dags# ls -l /opt/jdk1.8.0/bin/java
-rwxr-xr-x 1 uucp 143 8464 Dec 15 2018 /opt/jdk1.8.0/bin/java
root#1290ff36814b:/opt/airflow/dags# ls -l /opt/jdk1.8.0/
total 25996
-r--r--r-- 1 uucp 143 3244 Dec 15 2018 COPYRIGHT
-r--r--r-- 1 uucp 143 40 Dec 15 2018 LICENSE
-r--r--r-- 1 uucp 143 159 Dec 15 2018 README.html
-rw-r--r-- 1 uucp 143 112724 Dec 12 2018 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r-- 1 uucp 143 153824 Dec 15 2018 THIRDPARTYLICENSEREADME.txt
drwxr-xr-x 2 uucp 143 4096 Dec 15 2018 bin
drwxr-xr-x 3 uucp 143 132 Dec 15 2018 include
-rw-r--r-- 1 uucp 143 5211154 Dec 12 2018 javafx-src.zip
drwxr-xr-x 5 uucp 143 4096 Dec 15 2018 jre
drwxr-xr-x 5 uucp 143 4096 Dec 15 2018 lib
drwxr-xr-x 4 uucp 143 47 Dec 15 2018 man
-rw-r--r-- 1 uucp 143 424 Dec 15 2018 release
-rw-r--r-- 1 uucp 143 21105955 Dec 15 2018 src.zip
root#1290ff36814b:/opt/airflow/dags#
Why this happen?
I already tried to set JAVA_HOME and PATH, but still the same problem.
I just realize it has one space inside my python code where I export the JAVA_HOME. After remove it finally the code worked.
import os
import sys
os.environ["SPARK_HOME"]='/opt/spark-3.3.1'
os.environ["JAVA_HOME"]=' /opt/jdk1.8.0'
sys.path+=[os.environ["SPARK_HOME"]+"/python"]
sys.path+=[os.environ["SPARK_HOME"]+"/python/build"]
sys.path+=[os.environ["SPARK_HOME"]+"/python/lib/py4j-0.10.9.5-src.zip"]

Java, using class files from a .jar

so i am trying to use classes from a jar file i downloaded. The jar file is not in the same directory as the .java file that will use classes from the jar file.
I run
jar -tvf json-simple-1.1.1.jar
and I get
0 Sun Feb 19 14:30:56 CST 2012 org/
0 Sun Feb 19 14:30:56 CST 2012 org/json/
0 Sun Feb 19 14:30:56 CST 2012 org/json/simple/
3939 Sun Feb 19 14:30:54 CST 2012 org/json/simple/ItemList.class
2077 Sun Feb 19 14:30:54 CST 2012 org/json/simple/JSONArray.class
161 Sun Feb 19 14:30:54 CST 2012 org/json/simple/JSONAware.class
3076 Sun Feb 19 14:30:54 CST 2012org/json/simple/JSONObject.class
223 Sun Feb 19 14:30:54 CST 2012 org/json/simple/JSONStreamAware.class
3964 Sun Feb 19 14:30:54 CST 2012 org/json/simple/JSONValue.class
0 Sun Feb 19 14:30:56 CST 2012 org/json/simple/parser/
I want to implement ItemList.class, and I now know that it is in the package
org/json/simple/
so in my .java file I do
import org.json.simple.ItemList;
public class Foo(){
public static void main(String[]args){
ItemList i = new ItemList();
}
}
I now need to compile Foo() so I run
javac -cp '.;json-simple-1.1.1.jar' Foo.java
I get the error that the package org.json.simple does not exist but in github the class ItemList has package org.json.simple
Am I missing something? Thanks in advance
If the jar is not in the same directory you need to give the path to the jar directory when specifying the class path.

Why is my jar so big?

I've got a relatively simple jar-with-dependencies being built with Maven that is way larger than it seems like it should be. It's around 20MB, and in order to figure out what's taking up so much space, I've done the following:
First, I ran mvn dependency:tree. Then I checked in my .m2 cache for the size of each of the jars in the dependency tree. If I add up all of those sizes, it comes to about 8MB. How can I figure out where the other 12MB are coming from?
One thing I noticed in looking through my .m2 was that for many of the dependencies, they'll have something like this:
total 5224
-rw-r--r-- 1 user 289B Jul 25 2016 _remote.repositories
-rw-r--r-- 1 user 1.7M Jul 25 2016 commons-compress-1.12-javadoc.jar
-rw-r--r-- 1 user 407B Jul 25 2016 commons-compress-1.12-javadoc.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 25 2016 commons-compress-1.12-javadoc.jar.sha1
-rw-r--r-- 1 user 427K Jul 25 2016 commons-compress-1.12-sources.jar
-rw-r--r-- 1 user 407B Jul 25 2016 commons-compress-1.12-sources.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 25 2016 commons-compress-1.12-sources.jar.sha1
-rw-r--r-- 1 user 432K Jul 22 2016 commons-compress-1.12.jar
-rw-r--r-- 1 user 407B Jul 22 2016 commons-compress-1.12.jar.lastUpdated
-rw-r--r-- 1 user 40B Jul 22 2016 commons-compress-1.12.jar.sha1
-rw-r--r-- 1 user 13K Jul 22 2016 commons-compress-1.12.pom
-rw-r--r-- 1 user 407B Jul 22 2016 commons-compress-1.12.pom.lastUpdated
-rw-r--r-- 1 user 40B Jul 22 2016 commons-compress-1.12.pom.sha1
What are the -sources and -javadoc jars? Are those included in my uber jar? Because if every one of my dependencies uses the -javadoc jar instead of the standard one, that gets me a lot closer to 20MB.
Run
jar tvvf <your_simple-jar-with-dependencies.jar>
Or, open it with any zip compatible archiver and examine the contents to determine what is being included. Alternatively, run maven with -X for more extensive runtime information.

Gradle aapt not a file

I try to build a android app with android studio. Gradle throws this error when i try to build:
Gradle invocation completed successfully with 1 error(s) in 10 sec
and the message gradle build window shows:
Error:Execution failed for task
':SlidingUpPanelLayout:processReleaseResources'.
java.io.IOException: Cannot run program "/home/[...]/android-studio/sdk/build-tools/19.0.2/aapt": error=2, No
such file or directory
but ls -l shows me this files:
~/development/android-studio/sdk/build-tools/19.0.2$ ls -l
total 49348
-rwxr-xr-x 1 david david 1109734 Apr 12 12:29 aapt
-rwxr-xr-x 1 david david 271551 Apr 12 12:29 aidl
-rwxr-xr-x 1 david david 3570836 Apr 12 12:29 arm-linux-androideabi-ld
-rwxr-xr-x 1 david david 36534 Apr 12 12:29 bcc_compat
-rwxr-xr-x 1 david david 445402 Apr 12 12:29 dexdump
-rwxr-xr-x 1 david david 2577 Apr 12 12:29 dx
-rwxr-xr-x 1 david david 3570836 Apr 12 12:29 i686-linux-android-ld
drwxr-xr-x 2 david david 4096 Apr 12 12:29 lib
-rwxr-xr-x 1 david david 332357 Apr 12 12:29 libbcc.so
-rwxr-xr-x 1 david david 932160 Apr 12 12:29 libbcinfo.so
-rwxr-xr-x 1 david david 15372369 Apr 12 12:29 libclang.so
-rwxr-xr-x 1 david david 21101517 Apr 12 12:29 libLLVM.so
-rwxr-xr-x 1 david david 1667769 Apr 12 12:29 llvm-rs-cc
-rwxr-xr-x 1 david david 1919720 Apr 12 12:29 mipsel-linux-android-ld
-rw-r--r-- 1 david david 10800 Apr 12 12:29 NOTICE.txt
drwxr-xr-x 5 david david 4096 Apr 12 12:29 renderscript
-rw-r--r-- 1 david david 16649 Apr 12 12:29 source.properties
why say gradle the the aapt is not a file? whats wrong with it?
this helped me link
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

Error with image resources in jar file

I'm having a problem with running a jar file. If I compile the code in eclipse everything is ok, but when I export to jar and try to run the program it throws an error.
The error is:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at game.ChessSquare.<init>(ChessSquare.java:17)
at game.ChessFrame.DrawField(ChessFrame.java:131)
at game.ChessFrame.<init>(ChessFrame.java:38)
at game.Chess.main(Chess.java:7)
So the piece of code that throws this error is
//text is something like "pawn" or "king".The whole image is an icon on the button
img = new ImageIcon(getClass().getResource("white/"+text+".png"));
As I understand, it can't find the image so img variable is null. But I can't understand why then it does run in eclipse. Any help with this? Thanks
P.S #AndrewThompson
E:\Desktop>jar tvf chess.jar
49 Sat Feb 11 23:40:06 GMT 2012 META-INF/MANIFEST.MF
378 Sat Feb 11 22:51:04 GMT 2012 game/ChessFieldCoord.class
1932 Sat Feb 11 23:39:48 GMT 2012 game/ChessSquare.class
536 Sat Feb 11 22:51:04 GMT 2012 game/Chess.class
2122 Sat Feb 11 22:51:04 GMT 2012 game/Rook.class
2357 Sat Feb 11 22:51:04 GMT 2012 game/Bishop.class
1946 Sat Feb 11 22:51:04 GMT 2012 game/Queen.class
2127 Sat Feb 11 22:51:04 GMT 2012 game/Pawn.class
1630 Sat Feb 11 22:51:04 GMT 2012 game/Knight.class
878 Sat Feb 11 22:51:04 GMT 2012 game/Empty.class
1642 Sat Feb 11 22:51:04 GMT 2012 game/King.class
915 Sat Feb 11 22:52:32 GMT 2012 game/ChessFrame$1.class
841 Sat Feb 11 22:52:32 GMT 2012 game/ChessFrame$2.class
695 Sat Feb 11 22:52:32 GMT 2012 game/ChessFrame$3.class
3525 Sat Feb 11 22:52:32 GMT 2012 game/ChessFrame$Move.class
4675 Sat Feb 11 22:52:32 GMT 2012 game/ChessFrame.class
997 Sat Feb 11 22:51:04 GMT 2012 game/ChessFigure.class
928 Sat Feb 11 15:49:32 GMT 2012 game/black/bishop.png
1947 Sat Feb 11 15:49:10 GMT 2012 game/black/king.png
1247 Sat Feb 11 15:49:38 GMT 2012 game/black/knight.png
627 Sat Feb 11 15:49:44 GMT 2012 game/black/pawn.png
1668 Sat Feb 11 15:49:20 GMT 2012 game/black/queen.png
626 Sat Feb 11 15:49:26 GMT 2012 game/black/rook.png
1493 Sat Feb 11 15:48:30 GMT 2012 game/white/bishop.png
1889 Sat Feb 11 15:48:06 GMT 2012 game/white/king.png
1544 Sat Feb 11 15:48:40 GMT 2012 game/white/knight.png
1003 Sat Feb 11 15:48:48 GMT 2012 game/white/pawn.png
2440 Sat Feb 11 15:48:12 GMT 2012 game/white/queen.png
837 Sat Feb 11 15:48:20 GMT 2012 game/white/rook.png
The file where the error occurs is ChessSquare.class
img = new ImageIcon(getClass().getResource("/game/white/"+text+".png"));
Note the leading slash, as well as the game prefix.
As indicated in the comments, look in your jar (use winzip, 7zip, or something like that) to see where the resource is located. If it is not in a "white" directory then something is wrong with your jar build.
As to why it's running in Eclipse... that's likely because Eclipse is including the resource directory in the classpath when you run the program. This means that the getClass().getResource(...) call finds the png.
If you are keeping the file in a resources directory in Eclipse it also could be exporting the files into the META-INF directory in the jar, look in resources. If it is doing that then you may have setup the jar to be built for deployment into a web environment (see servlet 3.0 fragments).
One final note, be careful about using getClass().getResource(...) as it locks you down to only finding resources associated with the ClassLoader of the Class making that call (subject to how the ClassLoader hierarchy in question operates). You may want to provide extensions later where you can package other image sets in jars. In those cases you'll have to rely on slightly different mechanisms to get the images loaded (see ClassLoader.getResources as a starting point).
EDIT: This looks to be strictly an Eclipse problem. According to the way that the jar is structured the correct path is "game/white/king.png".
i'm an idiot, i finally figured out where the error was. As I wrote the output was "file:/E:/Desktop/Chess/bin/game/white/Pawn.png", notice the big P letter in Pawn.png. But the actual images' names started with small letters. That's why it didn't work. Still a mystery for me why then it worked in eclipse

Categories