Posts tagged java

Servers and Java WebGUI problems

posted on 2016-02-29 16:59:00

Often server and device manufacturers do ship their hardware with java-based administration hardware. Even more often, this stuff does not properly work due to your local java install not being up to date or complete. And if your installation is fine, the access to the server in place is restricted by security policies. (...)

Note: this guide is mostly linux specific. For Windows or OSX the steps may differ, even though Java is the same.

Most general steps for using these particular kinds of software are klicking a link, and getting a .jnlp file donwload offered. Afterwards you have to double klick that file, or maybe your system already knows how to open it. Java should start and lets your application run then.

If not, here are solutions to the most common problems.

no java web start application to start

  • no proper programm for running the java application

If you can donwload the .jnlp file, but cannot open it (even though you know you installed java!), it is simply lacking the proper program. Where your java binary is located, there must also exist a javaws binary ("Java Web Start"), which you need to open these files.

Either your system does not use javaws for starting them, but just download and try from the shell:

javaws <filename>.jnlp

Verify it is installed at all:

javaws -version

(All Java programs only use a single dash for their flags, only god knows why.)

app start prohibited due to security policy problems

In your shell, either one of these should work:

# or

Then the Java Control Panel should start.

Do ist

Choose the Security tab, and add your site URL to the Exception Site List. Afterwards your app should start upon reopening the .jnlp file.

guacamole: home folder location

posted on 2015-09-25 20:26:01

guacamole is a 'clientless rdp gateway' based on HTML5.

Sadly its pre-1.0 and has some hiccups.

One being the location of GUACAMOLE_HOME.

From its documentation:


Guacamole reads files from its own configuration directory by default, resorting to the classpath only when this directory cannot be found. When locating this directory, Guacamole will try, in order:

The directory specified within the system property guacamole.home.

The directory specified within the environment variable GUACAMOLE_HOME.

The directory .guacamole, located within the home directory of the user running the servlet container.

For tomacat7 that should be /usr/share/tomcat7/.guacamole. If you place folder somewhere else, without specifying the GUACAMOLE_HOME environment variable properly, no configuration will be loaded.

I have not read that excerpt above properly, and had to track that fact down in the source, maybe this will help someone.

In the source it were to be found here in line 44:

     1  public class GuacamoleHome {                                                     
     3      /**                                                                          
     4       * Logger for this class.                                                    
     5       */                                                                          
     6      private static final Logger logger = LoggerFactory.getLogger(GuacamoleHome.class);
     8      static {                                                                     
     9          // Warn about deprecation                                                
    10          logger.warn("GuacamoleHome is deprecated. Please use Environment instead.");
    11      }                                                                            
    13      /**                                                                          
    14       * GuacamoleHome is a utility class and cannot be instantiated.              
    15       */                                                                          
    16      private GuacamoleHome() {}                                                   
    18      /**                                                                          
    19       * Returns the Guacamole home directory by checking, in order:               
    20       * the guacamole.home system property, the GUACAMOLE_HOME environment        
    21       * variable, and finally the .guacamole directory in the home directory of   
    22       * the user running the servlet container.                                   
    23       *                                                                           
    24       * @return The File representing the Guacamole home directory, which may     
    25       *         or may not exist, and may turn out to not be a directory.         
    26       */                                                                          
    27      public static File getDirectory() {                                          
    29          // Attempt to find Guacamole home                                        
    30          File guacHome;                                                           
    32          // Use system property by default                                        
    33          String desiredDir = System.getProperty("guacamole.home");                
    35          // Failing that, try the GUACAMOLE_HOME environment variable             
    36          if (desiredDir == null) desiredDir = System.getenv("GUACAMOLE_HOME");    
    38          // If successful, use explicitly specified directory                     
    39          if (desiredDir != null)                                                  
    40              guacHome = new File(desiredDir);                                     
    42          // If not explicitly specified, use ~/.guacamole                         
    43          else                                                                     
    44              guacHome = new File(System.getProperty("user.home"), ".guacamole");  
    46          // Return discovered directory                                           
    47          return guacHome;                                                         
    49      }                                                                            
    51  }  

Tomcat memory settings on Debian

posted on 2014-08-27 17:57:37

To double all the base tomcat memory limits, use this:


JAVA_OPTS="-Djava.awt.headless=true -XX:+UseConcMarkSweepGC -Xms512m -Xmx1024m -XX:MaxPermSize=256m"

This edits the startup settings of tomcat. The parts in question are these:

# set the minimum heap size
# set the maximum heap size
# set the permgen space size

Try these if your tomcat has hickups.

Change tomcat's used java version

posted on 2014-08-12 10:20:19

To change the java version used, on a debian install, which is used by tomcat, change /etc/default/tomcat7.

There you have to change the JAVA_HOME setting accordingly.

Exporting JAVA_HOME by hand is no use, and changing the init script in /etc/init.d/tomcat7 is not just ugly and bad style, but michgt also be overwritten by future updates.

Debian java update-alternatives

posted on 2014-05-21 06:23:43

If you need javaws with oracle java (not that IcedTea crap), and have it installed already, but lost your settings due to an update, do:

$ update-alternatives --config javaws

This will show you something like this:

There are 6 choices for the alternative javaws (providing /usr/bin/javaws).

  Selection    Path                                              Priority   Status
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws   1071      auto mode
  1            /usr/lib/jvm/j2re1.7-oracle/bin/javaws             316       manual mode
  2            /usr/lib/jvm/j2sdk1.7-oracle/jre/bin/javaws        317       manual mode
  3            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws   1061      manual mode
  4            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws   1071      manual mode
  5            /usr/lib/jvm/java-7-oracle/bin/javaws              9         manual mode
  6            /usr/lib/jvm/java-7-oracle/jre/bin/javaws          1064      manual mode

Press enter to keep the current choice[*], or type selection number: 

Choose the according number and be happy.

Installing the Oracle JDK/JRE on Debian

posted on 2014-04-25 12:52:31

Sometimes you need the reference implementation (And not, i.e. the OpenJDK one that is easily available from the package repositories...) from the Oracle homepage. Might be you need exactly Java in v6 or v7 for IPMI for your Supermicro servers.

In this case several problem pop up:

  1. Oracle only provides .rpm and .tar.gz downloads.
  2. When getting the .tar.gz, might have problems installing it.
  3. Setting new package resources in /etc/apt/sources.list might also cause other problems, depending on the information you dig up from the internet.
  4. If No.3 works, you will run into the same trouble again, once you have to redo and regoogle what you did. (Of course this never happens. Haha.)
  5. Depending on what you install, you might miss the Java Web Start executable. Or it might be wrongly installed. (Of course, this never happens, either...)

So here is a better approach, which is easier to reproduce and will work.

First download the install of choice. (Choose the 32bit .tar.gz or the 64 bit one, according to your system. I.e. jdk-7u55-linux-x64.tar.gz)

$ apt-get install java-package
$ make-jpkg jdk-7u55-linux-x64.tar.gz

Say yes and ok, and let it work it's magic. Do not worry about error messages, at least in my case they were not of importance.

$ dpkg -i oracle-j2re1.7_1.7.0+update55_amd64.deb

And you are mostly done.

Only problem left might be that all is installed correctly, just the javaws not.

Check by running:

$ javaws

If this does not work, due to previously installed IcedTea implementation or whatnot, try this:

$ cd /etc/alternatives
$ ls java*

Then everything should point to the oracle install.

In my case everything did. Except the Web Start Link.

$ rm javaws
$ ln -s /usr/lib/jvm/java-7-oracle/bin/javaws javaws

Afterwards run

$ javaws

and you might see something like this:

[root@ctr-014 ~/Downloads]% javaws
Java(TM) Web Start 
Usage:  javaws [run-options] <jnlp-file>
        javaws [control-options]

where run-options include:
  -verbose              display additional output
  -offline              run the application in offline mode
  -system               run the application from the system cache only
  -Xnosplash            run without showing a splash screen
  -J<option>            supply option to the vm
  -wait                 start java process and wait for its exit

control-options include:
  -viewer               show the cache viewer in the java control panel
  -clearcache           remove all non-installed applications from the cache
  -uninstall            remove all applications from the cache
  -uninstall <jnlp-file>                remove the application from the cache
  -import [import-options] <jnlp-file>  import the application to the cache

import-options include:
  -silent               import silently (with no user interface)
  -system               import application into the system cache
  -codebase <url>       retrieve resources from the given codebase
  -shortcut             install shortcuts as if user allowed prompt
  -association          install associations as if user allowed prompt


Extract list of classes being used in legacy java project

posted on 2013-12-28 09:55:59

Currently I am working with a small sized legacy code base. To get a better overview, the actual LOC (lines of code) might be of interest:

# all lines including the whitespace
time \grep '.*' * -rc | cut -d ':' -f 2 | paste -sd+ | bc

Stripping the blank lines is left as an exercise to the reader.

This is ugly, but blazingly fast. time is just in there to see how fast things actually are.

Also a sorted list of all self-defined classes might make for a handy overview:

ack -h 'public class' | sed -e 's/^\s*//g' | cut -d " " -f 3-5 | sort | sort -k 2,3

Do yourself a favor, and use ack instead of grep. Nothing to regret in 99% of all use cases...

Run bash from Java

posted on 2013-11-11 08:12:38

Snippet from stackoverflow:

process p = Runtime.getRuntime().exec("");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;

while ((line = in.readLine()) != null) {
   // use bash script line output

I hope I do never have to resort this... but I have doubts. Since this works not only for shellscripts, but basically any executable producing console output. Will have to test this on different platforms i bet, though. Just to make it sure it runs where it has to.

The Java Language Specification

posted on 2013-10-30 10:25:36

When learning a programming language, there are verly likely some edge cases that you have trouble finding information on. If you use a language that has an official specification, the spec may be the last (and best) resort.

For Java SE 7, the online version can be found here. (Though I recommend the PDF from here, so you can search through the whole spec at once properly.)

Also having a closer look on it may prove useful someday. I.e. do you really know already every keyword in Java and its meaning? Let your curiousity get the better of you.

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apache2.4, apachebench, apple, applet, arcconf, arch, architecture, areca, arping, asa, asdm, autoconf, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blockdev, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, coleslaw, colorscheme, common lisp, configuration management, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fbsd, fdisk, fedora, file, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, github, gitolite, global, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pct, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plasma, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pveam, pvecm, pvesm, pvresize, python, qemu, qemu-img, qm, qmrestore, quicklisp, quickshare, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh

Unless otherwise credited all material Creative Commons License by sjas