ugh directory annoyances

How this happens I dont know , why it happens I dont want to know.
So here it goes , I have two shaders , vertshader.vert and fragshader.frag stored in the path src.com.lcass.core.shader, however when I put “src/com/lcass/core/shader/vertshader.vert” I get an error saying it cannot find the class , this has been going on for hours and as you can understand im a bit tepid , by that I mean im about to throw it at the wall.



public void init(){
	shader.attachVertexShader("src/com/lcass/core/shader/vertshader.vert");
	shader.attachFragmentShader("src/com/lcass/core/shader/fragshader.frag");
	shader.link();
	
}

Shouldn’t you have an extra [icode]src/[/icode] in front? I may be wrong but that looks like what’s wrong, because the eclipse root directory is one level up from the src folder and you have a src folder in the src folder.

CopyableCougar4

[I got some stuff wrong here]

shader.attachVertexShader("src/com/lcass/core/shader/vertshader.vert");
shader.attachFragmentShader("src/com/lcass/core/shader/fragshader.frag");

Should be

shader.attachVertexShader("src/src.com.lcass.core.shader/vertshader.vert");
shader.attachFragmentShader("src/src.com.lcass.core.shader/fragshader.frag");

That should fix the problem.

CopyableCougar4

Try putting a / at the front of the path.

Although without seeing the attach{Vertex,Fragment}Shader() functions there’s not much we can do to help.

My above code snippet fixes any errors AFAIK

CopyableCougar4

Hmm… However, if something is inside “src” its a ressource, part of the classpath and you cannot load it as a file (well, you can, but it will only work in your IDE, not when exported).

If it is a file, not a ressource (which is differently to load then a file), place it outside “src” and remove the “src”.

Although it does not work because its path doesnt start woth “src” but with “bin” in compiled state.

Wait, did you literally call the folder, [icode]src.com.lcass.core.shader[/icode]?

Yeah, he did.

CopyableCougar4

Was about to ask the same!

I suppose your methods load files, not ressources.

Okay: First you rename your packages and remove that “src” - why the hell do you have that!?
Then you move it OUTSIDE “src”. Then you remove “src” completely from the loader path.
When exportet, you’ll need to have your “com/lcass/core/shader” folder next to the jar, you can also rename it.

@Drenius

This fixes the problem more easily, granted it’s a nastier result for filepaths.

CopyableCougar4

if you bundle resource files inside the classpath (like /src/…) you need to access them like

getClass().getResourceAsStream("relative_path_to_current_class_which_does_this_call/resource.vert");

or

getClass().getResourceAsStream("/absolute_path_below_src/resource.vert");

easier to put everthing outside the src root and use [icode]new File("./shader/file.vert");[/icode] ./ refers to the current working directory then. running from an IDE this would be a directory next to src.