Function loadShader throwing a NullPointerException for no reason

Hi, I’m trying to make shaders in my Program, I have this code that loads a simple vertex Shader from his name to find it in the resources folder :

public void init() throws FileNotFoundException {
	try {
		Registry.register(getShader("fragment"), "basic");
	} catch (Exception e) {

public PShader getShader(String fragName) throws FileNotFoundException {
	String path = "src\\main\\resources\\shaders\\" + fragName + ".glsl";
	File file = new File(path);
	if (file.exists()) {"Fragment Shader " + file.getAbsolutePath() + " found.", "ShaderMapping");
		return sketch.loadShader(file.getAbsolutePath());
	} else {
		throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found.");

It register it into my Registry, all this happens in the setting function.
In the draw function at a point I do this :

Registry.getShaders().forEach((name, shader) -> {

To draw them.


In my loading part (in my setting function), where it loads the shader, I get this error :

	at processing.core.PApplet.loadShader(
	at processing.core.PApplet.handleSettings(
	at processing.core.PApplet.runSketch(

What I think that is oddly is that the Logger says it FINDS the shaders, without errors, it’s just where it load these that it send the error.
Look at my screen for proof.

1 Like

Were you able to resolve this issue?

Are you working in eclipse / IntelliJ (not PDE) and importing processing as a library to a Java sketch? I ask because -> is not supported by Processing 3 syntax, as used in PDE.

If Java, what version of Java are you using?

Is it possible that it’s trying to enable the shader before the P2D / P3D is set up and running?

1 Like