Font 'Arial' is not available to the JVM - java

I'm working on a Java project that uses Jasperreports. I worked several times in other projects using the same technology, and i had the same problem when trying to print a report in Unix environments.
My project uses:
JBoss 4.2.3.GA
Java 1.6
Jasperreports 4.7.0
The exception thrown is:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
I found a common solution to solve this issue and ir really works:
sudo apt-get install msttcorefonts
However, I want to understand how Jasper works with fonts, and how it searches this fonts installed in Unix environments. Maybe a better question is: how JVM handles native fonts? Can anyone give me a detailed explanation on this subject? How are system fonts made available for the JVM in runtime?

Java asks the OS to provide the fonts. How that works depends on the OS.
http://en.wikipedia.org/wiki/Arial states its is installed on MS-Windows and MAC OSX

If you don't want to go through the hassle of downloading jars and what not, just go to software-center and click install Ubuntu restricted extras. This package will install not only MS Fonts but other supports for applications with restricted copyright.
This works for Ubuntu Systems.

I was also facing the same issue on Jasper 5.0. I have followed the steps below:
Place the jasper-fonts.jar;
Install the missing fonts in the linux;
Restart the JBoss server.

Update for year 2015:
Add this to (or uncomment in) /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
Then run this:
sudo apt-get update
sudo apt-get install msttcorefonts

for OpenSuse
validate the fonts is no aviable on SO
fc-list | grep "Arial"
install the followin rpm
sudo rpm -ivh msttcore-fonts-2.0-3.noarch.rpm
or Download from page:
http://www.mjmwired.net/resources/mjm-fedora-f11.html#ttf
Install the rpm
validate again
fc-list | grep "Arial"
Restart your aplication server

this save my day !
http://jasperstarter.cenote.de/usage.html#Reports_with_custom_fonts
Reports with custom fonts
Jaspersoft Studio has an option to create a jar file of your fonts. Just put this jar file into the jdbc folder of JasperStarter.

Related

Java swing on eclipse oxygen 4.7.3a?

I am trying to use windowbuilder on eclipse oxygen 4.7.3a on macOS highSierra. it installed fine but every time I try to open the design part it displays this error
Eclipse is running under 0, but this Java project has a 1.8 Java
compliance level, so WindowBuilder will not be able to load classes
from this project. Use a lower level of Java for the project, or run
Eclipse using a newer Java version.
I tried everything. like changing the running enviroment, .jre files, try different JDE. nothing working. any suggestions?
Your only short term solution is to use a Java version <= 9.
Initially WindowBuilder did not work with Java 9 for several reasons. See
Bug 526098 - WindowBuilder fails to work on Java 9.
One of those issues was that the the System Property java.version was unexpectedly just "9":
Please check that you have exactly 9.0 JDK, it worked for me with
9.0.1 until I downgraded target JRE to 9.0, which has unusual System.getProperty("java.version").equals("9")
The fixes to get WindowsBuilder working on Java 9 were only completed on 2/21/18, and based on your error it looks like a similar issue exists when running WindowsBuilder using Java 10. I suggest you create a Bug Report with Eclipse.
See also:
SO Post Eclipse Oxygen Window Builder Error with Java SE 10.0.1 where the solution/workaround was to regress to Java 9.
This Eclipse Forum post where a user is reporting a similar problem to yours.
Uninstall Java Version and Install lower version of Java(8).Support for WindowBuilder is not provided anymore.
How to uninstall current version?(Mac)
Go to /Library/Java/JavaVirtualMachines/ to see current version of java and replace jdk1.8.0_131.jdk with yours.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf ~/Library/Application\ Support/Oracle/Java
Install Java 8:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Then:
Right click on your project and go to Properties
Make sure your configuration look like this,
At the top of picture Configure Workspace settings click on it (Uncheck project specification settings) and then see image below
Apply same as in picture Then enable "project specification settings"
Restart Your Eclipse
Done!!

How to fix font rendering in PHPStorm 10 in Linux?

Default font rendering always was rather ugly in Java apps in Linux. But there was good solution - OpenJDK font fix (openjdk-fontfix PPA in launchpad).
It worked great in PhPStorm 9 and previous versions, but it has stopped working in 10 version. Java options in config are identical.
Is there any way to fix font rendering?
Rendering before:
Rendering after:
Solution to fix this problem is simple: just rename jre folder in PHPStorm installation directory. Since 10 version app is bundled with its own JRE, so it doesn`t use system JRE by default.
Remove the bundled JRE
Add to
bin/phpstorm64.vmoptions
this two lines:
-Dswing.aatext=true
-Dawt.useSystemAAFontSettings=on
And in
Settings->Appearance & Behavior -> Apperance
Antialiasing:
IDE:Greyscale, Editor:Greyscale
At least on Arch Linux, when using OpenJDK, font rendering looks perfectly smooth. To force PHPStorm to use the system's OpenJDK instead of the bundled Oracle JDK, you have to set the environment variable WEBIDE_JDK to your OpenJDK path.
To do this in an update-safe manner, copy the .desktop file to your home dir:
$ cp /usr/share/applications/jetbrains-phpstorm.desktop ~/.local/share/applications/
And then change the content to:
[Desktop Entry]
Version=1.0
Type=Application
Name=PhpStorm
Icon=/opt/phpstorm/bin/webide.png
Exec=env WEBIDE_JDK=/usr/lib/jvm/java-8-openjdk "/opt/phpstorm/bin/phpstorm.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-phpstorm
Some times all of this doesn't work, if you use some distros.
In ubuntu's don't work font in sql panels and some popup's in editor.
In fedora's after install pathed jdk you can't see all fonts in editors.
For get good font rendering you should use patched jdf and distros with Infinality ( ROSA, Arch, RFRemix and etc.) or install it in your system.
Download patched jdk from https://code.google.com/p/tuxjdk/ and extract archive
Install it in your system and add new java in you enviropment:
sudo mv ~/Download/jdk-8u25-tuxjdk-b01/ /opt/jdk-8u25-tuxjdk-b01/
cd /opt/jdk-8u25-tuxjdk-b01/
#update-alternatives - for deb system's, for rpm use alternatives
sudo update-alternatives --install /usr/bin/java java /opt/jdk-8u25-tuxjdk-b01/bin/java 2
sudo update-alternatives --config java
export JAVA_HOME=/opt/jdk-8u25-tuxjdk-b01
export JRE_HOME=/opt/jdk-8u25-tuxjdk-b01
export PATH=$PATH:/opt/jdk-8u25-tuxjdk-b01/bin:/opt/jdk-8u25-tuxjdk-b01/jre/bin
Install Infinality. Some article don't do it and get good font rendering. But if you start coding in JetBrains products you can see that in some editor in popup's and some special panel haven't any antialiasing and looks so awful.
sudo add-apt-repository ppa:no1wantdthisname/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fontconfig-infinality
After all you should setup infinality rendering style. Best render i get with ubuntu style. This option you can't get with setstyle command, that's why you should edit settings file. And in this file, search for USE_STYLE (it should be USE_STYLE="DEFAULT" by default) and change it to "UBUNTU".
sudo -H gedit /etc/profile.d/infinality-settings.sh
After installing you should log out. If after all you see not good antyalyzing - configurete infinity for you system.
This solution tested on Ubuntu, Xubuntu, Kubuntu, Linux Mint KDE, Fedora 21-23, RFRemix 20-23 ( have infinality in default), ROSA Fresh KDE ( have infinality in default need only patched jdk). If it's don't work for you check folders path for java and setting infinality for you system.
Result:
I used Netbeans then phpstorm on linux mint.
Bad fonts appear in editor when using Oracle JDK , I removed Oracle JDK and netbeans fonts and menu problem mouse over fixed.
Recently I got phpstorm as prequests install Oracle JDK every thing work fine except fonts, I made deep search and test many soultion.
finally I just install OpenJDK latested one by:
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
for more about intalling openJDK
and in phpstorm there is option to select java on booting up :
check link to see:
https://www.jetbrains.com/help/phpstorm/switching-boot-jdk.html
just choose OpenJDK from list and restart phpstorm every thing will be work fine.

Fedora updates make Eclipse forget Java

(Not sure if this is an okay place to ask, but i'll try). After installing some updates in Fedora 16, Eclipse no longer knows how to use Java files. It can't make them, or compile them, or format the syntax. It's just eclipse without any Java whatsoever. I checked the yum.log and it installed about 6 eclipse updates and 2 java updates. A solution I found on the internet was to delete .eclipse and have eclipse regenerate it, but that didn't fix anything. Anyone know what's up?
The problem is documented here:
http://lists.fedoraproject.org/pipermail/devel/2012-January/161092.html
and this is the bug:
https://bugzilla.redhat.com/show_bug.cgi?id=760454
Basically, we were caught between a rock and a hard place and had to break a packaging loop so this broke people's existing installations. Move ~/.eclipse and restart Eclipse and you should be fine.
$ mv ~/.eclipse{,.bakBug760454}
I have faced a similar problem, it would be best in my opinion to remove every package for java and eclipse all together. You can find installed packages with:
sudo rpm -qa | grep keyword
where keyword would be for example 'jre', 'jdk' or 'eclipse'.
Once you find the packages you don't want, remove them with
sudo yum remove packagename
Then I would recommend you to skip default jdk available for linux and install the one provided from the Oracle website: http://www.oracle.com/technetwork/java/javase/downloads/index.html
I have installed version 6 myself as I had some maven problems (m2eclipse) with Java 7.
Download the rpm, install it and set you path to java in .bashrc file.
Check all your installed jre/jdk with
sudo alternatives --config java
or
sudo alternatives --config javac
and set the apropriate option if necessary.
Next, go to the eclipse website and download the latest stable release of eclipse and you should be fine. You can integrate it with the desktop as well so you won't have to start it from the command line every time.
Check all of the available eclipse* packages. "Eclipse" itself is just a plug-in platform with a lot of UI components, it's not a Java IDE unless you also install those plug-ins. It's possible that the packaging was changed in a way that the Java plug-ins were no longer included in the packages you have installed after the upgrade completed.

Eclipse 3.6 Helios for Ubuntu 10.10 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have ubuntu 10.10 net book edition installed on my dell studio laptop. I downloaded helios for the eclipse site but when I am not able to run it. I have downloaded eclipse 3.5 from synaptic package manager but I am not able to update eclipse 3.5 to eclipse 3.6. Is der any other way to have updated eclipse? Eclipse 3.6 supports HTML 5.
Please let me know, thanks a lot in advance
Try this:
To install eclipse on ubuntu you need to download it first from http://www.eclipse.org/downloads/
Extract the downloaded file by right click on it and extract here or running the following:
tar xzf dir/eclipse-SDK-3.3.1.1-linux-gtk.tar.gz
Where eclipse-SDK-3.3.1.1-linux-gtk is your eclipse-SDK name with version and dir is the directory of eclipse-sdk.
Now move it to the root directory. Apply the following command to do this.
sudo mv dir/eclipse ~
Now you are ready to configure your eclipse. To do this follow the following step by step...
sudo mv eclipse /opt/
Take care of the permissions:
sudo chmod -R +r /opt/eclipse
sudo chmod +x /opt/eclipse/eclipse
Create an executable in your path:
sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudo gedit /usr/bin/eclipse
Copy the following content and save the file:
#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*
Let’s also make eclipse executable everywhere by creating a symlink:
sudo ln -s /usr/bin/eclipse /bin/eclipse
Create the menu icon:
sudo gedit /usr/share/applications/eclipse.desktop
Type in this content and save:
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
Run for the first time:
eclipse -clean
You can now start Eclipse by simply typing eclipse in the terminal or from the GNOME menu Applications -> Programming -> Eclipse
At least, you still have the manual install, which leaves your current Eclipse3.5 untouched (allowing you to go back to it if 3.6 gives you too much troubles)
To get your 3.6 download running:
Unzip the download into a directory you have complete control of, usually a directory under your username, preserving folders.
Create a shortcut to the eclipse executable, usually in the resulting "eclipse" folder.
Run the program using the resulting shortcut.
When your new eclipse install starts, point to your existing workspace.
You can continue with both 3.5 and 3.6 installed using the same workspace, or you can remove 3.5 by deselecting it from your software management program (one of several ways).
Alexander Pogrebnyak actually points out in the comment:
workspace cannot round trip 3.5->3.6->3.5.
The usual solution is to keep 3.5 and 3.6 versions of workspace in different directories.
The idea to have one workspace for each version is always the safest route to take, with each of your project imported into each respective workspace.
Note, you have to make sure your java is correctly installed (which should be already good for you, but just in case):
Installing Helios 3.6 on Ubuntu 10.10 is rather simple.
Download eclipse package from eclipse.org and extract it to a folder in your home directory.
The tricky part is setting up java6-jdk from the sun partner repository but there is a easy to follow guide:
basically you have to enable the partner repository, then install java6 jdk with:
sudo apt-get install sun-java6-jre sun-java6-plugin
and then if necessary update your java alternatives with:
# shows a list with available java alternatives:
sudo update-java-alternatives -l
# sets the alternative
sudo update-java-alternatives -s java-6-sun
sudo update-alternatives --config java
The Eclipse version available through the official Ubuntu channels is 3.5 and should not be manually upgraded to 3.6. You probably will not have write permission to do so.
If you must have 3.6 the easiest way is to download the official distribution from eclipse.org, unzip it and run the eclipse binary directly. This also allows you to fully administer it by yourself with upgrades and extra modules.
The Eclipse version available through the official Ubuntu channels is 3.5 and should not be manually upgraded to 3.6. You probably will not have write permission to do so.
There is a PPA available, that should let you upgrade through package management before the packages reach the Ubuntu repos. Sadly, the packages seem broken right now.

Java on Debian: Probable fatal error: No fonts found

I want to run Tomcat on Debian 5 Minimal. So I don't need a gui for my OS, it's just a pure Tomcat-Server.
Which packages do I need for my JVM to use Fonts in my applications? Im drawing texts in Graphics2D and am creating PDF-Files in my Java-Project.
I had similar problem on CentOS, after crunching for a solution..
I solved this problem by installing fonts like follows:
sudo yum install bitmap*
sudo yum install dejavu-lgc*
sudo yum install bitstream-vera*
Graphics2D and anything in the java.awt.* or java.swing.* packages require a GUI to do its drawing.
This is a problem on most headless servers. You have two options, and try them in this order:
Use the system property "java.awt.headless" and set that to "true"
java -Djava.awt.headless=true or System.setProperty("java.awt.headless", "true");
Install the XWindows Virtual Frame Buffer (xvfb) on your server. This keeps the server headless, but provides the XWindows primitives needed to draw on a virtual screen. It is far from optimized (no graphics acceleration), but it will allow your system to work again.
The java.awt.headless option was introduced with Java 1.4. See: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
In the event that does not work, install the XVFB package and configure it to create a virtual frame buffer large enough to do your drawing.
I fixed this by installing some fonts (under Ubuntu) by:
apt-get install msttcorefonts
They should be installed in /usr/share/fonts/truetype/.
Dont forget to restart Tomcat if you use it.
None of the answers above worked for me on a Amazon Linux AMI with OpenJDK 1.6.0_20. However this worked:
sudo yum install dejavu*
ln -s /usr/share/fonts/dejavu /usr/share/fonts/dejavu-lgc
The first line installs some default fonts, and the second ensures that Java finds them. More at http://brandon.fuller.name/archives/2011/09/12/00.05.15/
I encountered this issue with Atlassian Bamboo recently. On Scientific Linux all that I was required to do was:
sudo yum install dejavu*
(Unlike mkvalsvik I did not need to make a symlink).
For me, this has solved it: https://bugzilla.redhat.com/show_bug.cgi?id=708201
Basically the 'java' package did not depend on 'fontconfig', which had to be manually installed.

Categories

Resources