GithubHelp home page GithubHelp logo

tjpdj1988 / ghostawt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielku15/ghostawt

0.0 2.0 0.0 938 KB

Run Java Swing/AWT applications on headless environments

License: MIT License

C 24.26% Java 75.74%

ghostawt's Introduction

GhostAWT

GhostAWT is a Java library for running Java Swing/AWT applications on headless environments like Servers and NAS-Systems.

The Problem

If you try to run Java GUI applications on environments without a Graphical User Interface you will have an XServer to be installed on the system, but often you do not want to install an XServer, Xvfb or a VNC Server on your System for only running a particular Java application which has a User Interface. That's where GhostAWT comes in place.

The Solution

Since Java is a multiplatform language there must be some sort of platform abstraction, and there is. GhostAWT is an implementation of that abstraction layer for headless environments. GhostAWT provides an empty implementation for all AWT and Java2D operations which makes any Java AWT or Swing application believe that there is a Graphicsl User Interface available on the system.

There is already a mechanism in Java called Headless Mode. But if you try to create any UI Components, you just get a HeadlessException which prevents you from proceeding. Using GhostAWT you can bypass this problem and create AWT and therefore Swing Component instances without a window system.

Usage

  1. Download the GhostAWT packages from the releases
  2. Place GhostAWT beside your Java Application
  3. Ensure the ghostawt.jar is in your classpath
  4. Use ghostawt.GhostRunner as your main class and pass your other main class and arguments to it.
  5. Set -Dghostawt.library.path to point at the library path of your platform
java  -Dghostawt.library.path=libs/ghostawt/linux32 -cp "bin:libs/ghostawt/ghostawt.jar" ghostawt.GhostRunner my.main.Class additional arguments

Usage (Pro Users)

  1. Download the GhostAWT packages from the releases
  2. Place GhostAWT beside your Java Application
  3. Find out the original value of sun.boot.library.path by entering
java -XshowSettings:properties -version

You will find some value after sun.boot.library.path= keep those paths in mind. In my case this is: /usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386

  1. Start your Java Application using a commandline similar to this:
java -Dawt.toolkit=ghostawt.GhostToolkit \
     -Djava.awt.graphicsenv=ghostawt.image.GhostGraphicsEnvironment \
     -Djava.awt.headless=false \
     -Dsun.font.fontmanager=ghostawt.sun.GFontManager \
     -Dsun.boot.library.path=ghostawt/linux32/:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386
     -cp "./*" my.main.Application

Explaination

-Dawt.toolkit=ghostawt.GhostToolkit - Makes Java use the Ghost AWT Toolkit implementation

-Djava.awt.graphicsenv=ghostawt.image.GhostGraphicsEnvironment - Makes Java use the Ghost Java2D implementation for graphic operations

-Djava.awt.headless=false - Ensures the headless-detection mechanism of Java does not think we are on a headless environent

-Dsun.font.fontmanager=ghostawt.sun.GFontManager - Makes Java use the Ghost Font Manager for loading system fonts

-Dsun.boot.library.path=ghostawt/linux32/... - Makes Java use the native libraries of this directory instead of the internal one. Notice that the path from step 3 is added to this path list.

ghostawt's People

Contributors

danielku15 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.