Headless Java rendering - cannot initialise
in
Integration and Hardware
•
2 months ago
Hi,
Trying to render some sketechs on my headless linux server - found neat tutorial but for some reason I am unable to initialize PApplet - Probably some minor error somewhere. Thanks for help
Code snippet where I believe is the mistake:
- public void initialize(int _width, int _height) {
- System.out.println("Initializing renderer...");
- try {
- // create a PApplet object and retrieve its graphics context
- applet = new PApplet();
- context = applet.createGraphics(300, 300, "PDF"); //in here I tried P2D, PApplet.P3D etc..
- applet.g = context;
- // load our basic student image
- System.out.println("Initialization complete");
- } catch (Exception e) {
- e.printStackTrace();
- }
- Initializing renderer...
- java.lang.NullPointerException
- at processing.core.PApplet.makeGraphics(PApplet.java:1791)
- at processing.core.PApplet.createGraphics(PApplet.java:1757)
- at HeadlessClassroom.initialize(HeadlessClassroom.java:31)
- at HeadlessClassroom.main(HeadlessClassroom.java:73)
- Null applet/context
- Call initialize() before rendering
1