asked on
ASKER
ASKER
Then could you explain why it worked in the same levelThe reason is that there are two basic way to load resources. The way that your instructor has coded it in this example, is loading the resources from the "file system". What has happened here is that the code is trying to load a file specified as a relative path, ie. "input.txt" and so Java is looking for that in what the "current" directory is when the code is run. In the case of Eclipse, the current directory is set to the projects base directory.
What has happened here is that the code is trying to load a file specified as a relative path, ie. "input.txt" and so Java is looking for that in what the "current" directory is when the code is run.So, bear in mind that it's very difficult to predict what the current directory will be when real (as opposed to IDE) code is run and therefore to stop your app breaking. That's a principal reason not to do it that way.
ASKER
Why is it still Cross signs ? Is there any other thing which i should doAs I alluded to in my post, you would have to go through your instructors code and change all the points where it loads resources, from accessing "file" resources to accessing "class" resources. To advise any further, I would really need to see exactly how the existing code is currently loading those resources.
It's so problematic. Why is it still Cross signs ? Is there any other thing which i should do which is not told in that link ?Well, it's only the resource loading which you should be looking at there. I'm guessing that you could be changing some of the correct source (.java) stuff too. Difficult to know without seeing your full code or directory contents
ASKER
image = ImageIO.read(getClass().getResourceAsStream("/resources/example2.gif"));
but that wasn't the reason for your 'red cross' error
ASKER
Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.
TRUSTED BY
Maybe you could even tell us WHAT the error is that you are getting?
What are you "importing" it into?
Depending on how much code there is, can you post the code here?