Running Java in Cloud9IDE?

runner
builder
java

#1

Hello there! Im confused on how to run java applets in my cloud9… Here is my progress so far:
https://ide.c9.io/amanuel2/javaliu#openfile-README.md

When i click the run button i get:

Building twentyone.java and running twentyone                                                                                                                                                       
bash: line 3: javac: command not found                                                                                                                                                              
Error: Could not find or load main class twentyone  

Here is the code in twentyone.java:

import java.applet.Applet;
import java.awt.*;

/**
 * Created by Amanuel on 4/18/2016.
 */
public class twentyone extends Applet {
    protected int x1 = 40,y1=35,x2=30,y2=35;
    @Override
    public void paint (Graphics page)
    {
        setBackground (Color.CYAN);
        page.drawLine(100,120 ,100,100);
        page.drawLine(100,100,80,100);
        page.drawLine(80,100,80,70);
        page.drawLine(80,70,60,70);
        page.drawLine(60,70,60,50);
        page.drawLine(60,50,40,50);
        page.drawLine(40,50,40,35);
        page.drawLine(40,35,30,35);
    }
}


#2

As I saw when we were on a collaborative terminal session, it seems you need an X environment to compile/run your applet. (You installed open-jdk, so javac is not anymore a problem)

This topic (more precisely this github repository) will help you get one for your workspace.
Do this:
git clone https://github.com/fjakobs/cloud9-vnc cd cloud9-vnc sh ./install.sh
Then, modify line 6 of ~/cloud9-vnc/run.sh to match supervisord.conf location with this:
cd /home/ubuntu/workspace/cloud9-vnc

Then you can run sh ./run.sh and open https://javaliu-amanuel2.c9users.io/vnc.html, click connect and you will see your desktop.
Left-click to open a bash terminal and from ther you can run appletviewer in this X environment.

Hope it helps.
Feel free to ask if something goes wrong.


#3

The thing works now… but when i run appletviewer i get:

Exception in thread "main" java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
        at java.awt.Window.<init>(Window.java:535)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at sun.applet.AppletViewer.<init>(AppletViewer.java:159)
        at sun.applet.StdAppletViewerFactory.createAppletViewer(AppletViewer.java:100)
        at sun.applet.AppletViewer.parse(AppletViewer.java:1140)
        at sun.applet.AppletViewer.parse(AppletViewer.java:1074)
        at sun.applet.Main.run(Main.java:156)
        at sun.applet.Main.main(Main.java:98)

#4

@EtienneWan worked it out fourtunately! :smiley: We just adjusted some stuff -.- … and it worked. If you guys are aiming at making java applets, you can just go to that c9.io workspace i posted above and try to immitate it! Thanks to @EtienneWan !


#6

that github repository no longer exists. What did it contain?


#7

there is a fork at https://github.com/EtienneWan/cloud9-vnc