A problem which may occur in Eclipse is that it opens the
.class
file (the compiled file) instead of opening the .java
file when you do this. This is probably caused by the order of the entries in the .classpath
file.Go to your project directory and open the .classpath file. Move all entires of type
classpathentry
with attribute kind="src"
to the top of the file (or at least above any entries with kind "output").Restart Eclipse and the problem should be fixed.
It's not working, all my scr kind entries is on the top. :(
ReplyDelete@SaNNyO: Difficult to say why it might not work, here are some ideas:
ReplyDelete1. Are you sure you are editing the correct file? Make sure it's the one in the project you are looking at. :)
You can apparently also do these changes by right-clicking your project in Eclipse, select Properties, select Java Build Path, select the Order and Export tab, and then move the folders to the top using the 'Up' button.
2. A restart of Eclipse should catch any changes you do, but you might want to try to refresh the project too. Right-click the project and select 'Refresh'.
3. Maybe you don't have the source for the class/method you are trying to open. This could happen if it is an added library (JAR) or part of Java Core. Check out http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-properties-source-attachment.htm to see if you can add the source to your JARs.
Also see http://stackoverflow.com/questions/4035400/classpath-build-order-changes
you can make it using eclipse it self without restarting
ReplyDeleteright click on your project -> java build path -> order and export ->(select the type src) -> top ->ok
@Shrif your're right, that should do it. I've noticed however that sometimes Eclipse needs a good restart to pick up on the changes you do.
DeleteYour way keeps one from having to mess around in the file system and find the correct lines in the classpath file.
Notice that in the Order and Export dialog in Eclipse, the source items will have folder icons just like in the project tree itself in Eclipse. Makes it easier to find the source items.
Java file was opening properly previously and I have not made any changes then why it is opening class file. what is actual reason behind this?
ReplyDelete