Java on Debian: Probable fatal error: No fonts found - java

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.

Related

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.

How to find root of "Could not find or load main class" error when running JAR

I have seen this question asked so many times, but there was no precise answer to my problem. My story is simple - I downloaded a legitimate JAR file, for a functioning and advertised application, from here: https://github.com/kamilfb/mqtt-spy/wiki/Downloads.
The application brings the obvious instruction to start it as java -jar mqtt-spy-0.2.0-jar-with-dependencies.jar but that results in the well known error, being in my case Error: Could not find or load main class pl.baczkowicz.mqttspy.Main
My system is Ubuntu 15.04, Java version is
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
I don't have another computer to test it elsewhere. I did some checks and the JAR file looks pretty much normal. I even tried de-compressing it and running the class directly, it won't budge, same error message. I tried some online .class analysis tools, nothing caught my attention. Also I reviewed about a dozen of pages referring to "Could not find or load" problem. No luck so far.
Not sure if anyone bothers, but I did my Java Programmers certification with Sun yet in 2005... and I feel frustrated now. While I hope there is an easy solution for my problem, e.g. some nice Ubuntu issue ;-), I am ready to dig deeper, and looking for any hints that would guide me to finding the root cause of this issue.
Additionally install Java FX, since this is required and worked for me (Ubuntu 16: package openfx):
apt install openjfx
See also this issue:
https://github.com/kamilfb/mqtt-spy/issues/88
I currently successfully run it on openjdk version "1.8.0_121" here.
Thank you it was very helpful for me. I had exactly the same problem, and looking the solution here as well
My fix was:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
then, install the JDK Oracle 8
sudo apt-get install oracle-java8-installer
and then, checking java:
sudo update-alternatives --config java
It is displayed between other choices:
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1082
auto mode
......
Press to keep the current choice[*], or type selection number:
I keep the 0 current choice [*]
then, running mqttspy worked just fine :-)
java -jar mqtt-spy-0.5.1-jar-with-dependencies.jar
The solution that worked in my case was to use HotSpot Java 8, from Oracle.
Just in case you have multiple java versions, you can run the jar file by giving the java file path as well.
brew install --cask liberica-jdk#17-full
brew install --cask liberica-jdk17-full
/Library/Java/JavaVirtualMachines/liberica-jdk-17-full.jdk/Contents/Home/bin/java -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar

Installing Java Runtime with Saltstack

I'm using Salt to configure a bunch of Centos machines (rpm-based) and I need to install the Java runtime. I've seen some discussion of doing this with Ubuntu-based machines but I wonder if anybody has done it on Redhat-based distros. The problem is getting past the "accept license" dialog without user intervention.
You can actually pre-seed the answers to those interactive questions. Here's a thread from the salt-users mailing list showing how: https://groups.google.com/d/msg/salt-users/95Q707FFWYo/CdcJN7FPpRAJ
There is this nice saltstack-formula/sun-java-formula
Formula to set up and configure Java JREs and JDKs from a tarball archive sourced via URL.
It can be installed using formulas documentation. I did not test this on a centos installation, but it uses tarball installation so maybe it would work. If someone tests it on a rvm based system, please comment here! ;)
I successfuly installed this on a debian machine with the following pillar:
java_home: /usr/lib/java
java:
source_url: http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jre-7u79-linux-x64.tar.gz
jce_url: http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip
version_name: jdk1.7.0_79
prefix: /usr/share/java
dl_opts: -b oraclelicense=accept-securebackup-cookie -L
It installed java-jdk successfully, but it failed to install jce. I created issue #20 for this just in case, but I don't actually need jce (at least, not now).

Font 'Arial' is not available to the JVM

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.

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.

Categories

Resources