1

I'm trying to integrate the graphstream library into my java applet. The applet works on Eclipse and when I use the appletviewer utility but when I run the html file with the applet embedded, it only renders grey screen.

Here's the error that I get whenever I run the html file with java applet. (I tested it on Internet Explorer)

Java Plug-in 11.66.2.18
Using JRE version 1.8.0_66-b18 Java HotSpot(TM) Client VM
User home directory = C:\Users\mark
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@187b275
security: Expected Main URL: file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar
basic: Plugin2ClassLoader.addURL parent called for file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar
basic: Plugin2ClassLoader.addURL parent called for file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
network: Cache entry found [url: file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar, version: null]
cache: Adding MemoryCache entry: file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar
cache: Resource file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar has expired.
network: ResponseCode for file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar : 200
network: Encoding for file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar : null
CacheEntry[file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar]: updateAvailable=false,lastModified=Mon Dec 07 16:01:59 CST 2015,length=8212
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@d725590a: 1
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@d725590a: 2
security: Blacklist revocation check is enabled
security: blacklist: created: NEED_LOAD, lastModified: 1449401487364
security: The jar file isnt signed so the blacklist check will be skipped
security: Trusted libraries list check is enabled
security: Trusted libraries list file not found
cache: Reading Signers from 5 file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar | C:\Users\mark\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\52\539c2334-19921083.idx
network: No certificate info for unsigned JAR file: file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar
cache: Done readSigners(file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar)
cache:  Read manifest for file:/C:/Users/mark/workspace/JavaApplet/bin/swingGraph.jar: read=85 full=85
network: Created version ID: 1.8.0.66
network: Created version ID: 1.8.0.65
network: Created version ID: 1.8.0.66
network: Created version ID: 1.8.0.65
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@d725590a: 3
security: SSV validation:
    running: 1.8.0_66
    requested: null
    range: null
    javaVersionParam: null
    Rule Set version: null
network: Created version ID: 1.8.0.66
network: Created version ID: 1.8.0.66
security: continue with running version
security: JUT Record:
    plugin2
    file://C:\Users\mark\workspace\JavaApplet\bin\myapplet.html: launchjnlp= code=swingGraph.SwingGraphApplet codebase=file:///C:/Users/mark/workspace/JavaApplet/bin/ width=800 archive=./swingGraph.jar,../lib/gs-core-1.3.jar height=500  app_model=eJyNU91qE0EUPtmkTWpDhYg3FkGkogjdoYgt6FUIRVpWKE37AJPNNDvt7s44czbZeFHwJQQvfAPfw3ufwVvfQNAzu5sfqYTsxezMzjnf+b7znf32Czasgd1QJb7NUn8odKymvhFXflfr92ooYiifmgf3AmiF9GnArUDYCa75mLNUILs8D94GsD0UNjRSo1QpQqe8jnk6Yn00Mh1RSEfkKFJLAefCqsyEwiI8LCMzlDHrGsOngbRIwe1rbuZhH+AW6lQ/ViF3Bdy5FsBWwmXai7ktAjxKsiLMjMSp447wMiBljJSxUhkjZWymbK+/FEsFN1BiLCqgBk41ATxdCXBBMZS4ORbpUJkiM9fUz7ZT5FNrfGrN52dHh49+/zR1aJ5AK+I26lHyCTS0MkgSeIaRcjRmla/kgkWkLFb7ljYKVaji6lwnKlXJP9WDAAgvWO8Nu7TCWJZwc8MmytxYzUPBTokVcY/JsoFMmUvewrKeLng/KHg7J/y5E/mnH4+/fOdf61AjzlZ+FLl2AzFpuDUvGt+mnVd88Ajl+Ypp2jtdmLqYLO+us80xCaiOrqnu3ZzprJgfrqvUTmj+3hmuI5+Gqsh2y7augO//F/5oHfhYDtjI7ofKiP0D/9Ud/PxfaI3wel3WyZQXBz/CJC6sraxC2F1S1J9vy1y9+vrWwJNVBrmZrpyBDhlsYKeYCvcn+8dplixfUq3N7tlZcHyh/wIhUG1n
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 309164 us, pluginInit dt 512505 us, TotalTime: 821669 us
network: Cache entry found [url: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar, version: null]
cache: Adding MemoryCache entry: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
cache: Resource file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar has expired.
network: ResponseCode for file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar : 200
network: Encoding for file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar : null
CacheEntry[file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar]: updateAvailable=true,lastModified=Mon Dec 07 14:36:53 CST 2015,length=1033670
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@fbedeb27: 1
cache: Resource file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar has expired.
network: ResponseCode for file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar : 200
network: Encoding for file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar : null
network: Server response: (length: 992680, lastModified: Tue Apr 07 12:21:14 CST 2015, downloadVersion: null, mimeType: application/x-java-archive)
network: Downloading resource: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
    Content-Length: 992,680
    Content-Encoding: null
network: Wrote URL file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar to File C:\Users\mark\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\5\218096c5-322fa223-temp
security: The jar file isnt signed so the blacklist check will be skipped
security: Trusted libraries list file not found
network: CleanupThread used 356788 us
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=false, hasSingleCodeSource=false, hasMissingSignedEntries=false}
network: CleanupThread used 3 us
network: Cache: Enable a new CacheEntry: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
network: Remove cache entry: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
cache: MemoryCache: removed entry file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
network: Downloaded file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar: C:\Users\mark\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\5\218096c5-322fa223
cache: Adding MemoryCache entry: file:/C:/Users/mark/workspace/JavaApplet/lib/gs-core-1.3.jar
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@fbedeb27: 1
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@fbedeb27: 2
java.lang.reflect.InvocationTargetException
    at java.awt.EventQueue.invokeAndWait(Unknown Source)
    at java.awt.EventQueue.invokeAndWait(Unknown Source)
    at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
    at swingGraph.SwingGraphApplet.init(SwingGraphApplet.java:11)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
    at org.graphstream.ui.graphicGraph.stylesheet.Rule.<init>(Rule.java:80)
    at org.graphstream.ui.graphicGraph.stylesheet.StyleSheet.initRules(StyleSheet.java:303)
    at org.graphstream.ui.graphicGraph.stylesheet.StyleSheet.<init>(StyleSheet.java:99)
    at org.graphstream.ui.graphicGraph.GraphicGraph.<init>(GraphicGraph.java:229)
    at org.graphstream.ui.view.Viewer.<init>(Viewer.java:247)
    at swingGraph.SwingGraphPanel.<init>(SwingGraphPanel.java:21)
    at swingGraph.SwingGraphApplet.createGUI(SwingGraphApplet.java:22)
    at swingGraph.SwingGraphApplet$1.run(SwingGraphApplet.java:13)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.RuntimeException: corrupted graphstream.jar ? the org/miv/graphstream/ui/graphicGraph/rgb.properties file is not found
    at org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.<clinit>(StyleConstants.java:241)
    ... 22 more
basic: Applet initialized
basic: Starting applet
basic: completed perf rollup
basic: Applet made visible
basic: Applet started
basic: Told clients applet is started

Here's my applet code: 1. SwingGraphPanel.java

package swingGraph;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.MultiGraph;
import org.graphstream.ui.swingViewer.ViewPanel;
import org.graphstream.ui.view.Viewer;

public class SwingGraphPanel extends JPanel implements ActionListener {
    private MultiGraph graph = new MultiGraph("Multigraph");
    private static final long serialVersionUID = 3280131219271802894L;
    private Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    private ViewPanel view = viewer.addDefaultView(false);

    private static String ADD_COMMAND = "add";
    private static String REMOVE_COMMAND = "remove";
    private static String CLEAR_COMMAND = "clear";


    public SwingGraphPanel() {
        super(new BorderLayout());

        JButton addButton = new JButton("Add");
        addButton.setActionCommand(ADD_COMMAND);
        addButton.addActionListener(this);

        JButton removeButton = new JButton("Remove");
        removeButton.setActionCommand(REMOVE_COMMAND);
        removeButton.addActionListener(this);

        JButton clearButton = new JButton("Clear");
        clearButton.setActionCommand(CLEAR_COMMAND);
        clearButton.addActionListener(this);

        JPanel panel = new JPanel(new GridLayout(0,3));
        panel.add(addButton);
        panel.add(removeButton);
        panel.add(clearButton);
        add(panel, BorderLayout.NORTH);


        add(view, BorderLayout.CENTER);

        Node nodeA = graph.addNode("A");
        nodeA.addAttribute("xy", 0, 0);
        Node nodeB = graph.addNode("B");
        nodeB.addAttribute("xy", 10, 0);
        Node nodeC = graph.addNode("C");
        nodeC.addAttribute("xy", 10, 10);

        graph.addEdge("AB", "A", "B");
        graph.addEdge("BC", "B", "C");
        graph.addEdge("CA", "C", "A");

        graph.addAttribute("ui.quality");
        graph.addAttribute("ui.antialias");
    }

    public static void createAndShowGui() {
        JFrame frame = new JFrame("Graph Swing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        SwingGraphPanel graphPanel = new SwingGraphPanel();
        graphPanel.setOpaque(true);
        frame.setContentPane(graphPanel);
        frame.setSize(500, 500);
        frame.setLocationRelativeTo(null);

        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGui();
            }
        });
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }
}

2. SwingGraphApplet.java

package swingGraph;

import javax.swing.JApplet;
import javax.swing.SwingUtilities;

public class SwingGraphApplet extends JApplet {
    private static final long serialVersionUID = 676241475056525767L;

    public void init() {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    createGUI();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void createGUI() {
        SwingGraphPanel graphPanel = new SwingGraphPanel();
        graphPanel.setOpaque(true);
        setContentPane(graphPanel);
    }
}

And here is my html file code

<html>
<head>
</head>

<body>
    <applet archive="./swingGraph.jar,../lib/gs-core-1.3.jar"
                    code="swingGraph.SwingGraphApplet"
                    width="800"
                    height="500">
    </applet>
</body>
</html>

===== EDIT ======

Here's the output of "jar -tvf gs-core-1.3.jar"

http://textuploader.com/5uojf

hypergamer003
  • 193
  • 1
  • 2
  • 11
  • `setSize(800, 500);` That should be (and already is) set in the HTML.`setVisible(true);` That is the default for an applet. – Andrew Thompson Dec 07 '15 at 07:34
  • Change `System.err.println("Error in creating GUI");` to `e.printStackTrace();` and report the new output. – Andrew Thompson Dec 07 '15 at 07:48
  • I edited the error message. There's this "java.lang.reflect.InvocationTargetException" – hypergamer003 Dec 07 '15 at 08:08
  • More interesting in that exception is the 'caused by', which can be more than one thing, and in this case, two. The 2nd one is `Caused by: java.lang.RuntimeException: corrupted graphstream.jar ? the org/miv/graphstream/ui/graphicGraph/rgb.properties file is not found` .. Is that resource inside the graph stream Jar in the appropriate location? Try validating the Jar against a newly downloaded version of the same thing. – Andrew Thompson Dec 07 '15 at 08:20
  • Hi. It seems that there is no folder graphstream inside the org/miv folder. Here is the picture of the file directory of gs-core-1.3.jar http://postimg.org/image/rhanvt22p/ – hypergamer003 Dec 07 '15 at 08:25
  • The text output of `jar -tvf the.jar` would be more useful than screenshots. – Andrew Thompson Dec 07 '15 at 08:31
  • Here is the output of "jar -tvf gs-core-1.3.jar" http://textuploader.com/5uojf – hypergamer003 Dec 07 '15 at 08:39
  • Interestingly it does include this though.. `12750 Tue Apr 07 11:49:26 CST 2015 org/graphstream/ui/graphicGraph/stylesheet/rgb.properties` If there were a `miv` between `org` & `graphstream`, it could be the file it needed. What is the significance of the `miv`? Are there other Jars supplied for the graph stream API? – Andrew Thompson Dec 07 '15 at 08:52
  • I looked into the source file that causes this exception. http://postimg.org/image/k5qmeva49/ The "StyleConstants.java" file as well as the "rgb.properties" file is in org\graphstream\ui\graphicGraph\stylesheet Inside the miv folder are only class files. – hypergamer003 Dec 07 '15 at 09:09
  • There are other jars for the graphstream api (algo and ui jars) but i don't use any of the classes in those jars in my code – hypergamer003 Dec 07 '15 at 09:40
  • FYI this question has been answered here : http://sympa.litislab.fr/sympa/arc/graphstream-users/2015-12/msg00001.html – Yoann Dec 08 '15 at 14:44

0 Answers0