Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » F3 opens the classB.class file instead of the classB.java file
F3 opens the classB.class file instead of the classB.java file [message #1007927] Fri, 08 February 2013 08:54 Go to next message
Leon Zeng is currently offline Leon ZengFriend
Messages: 1
Registered: February 2013
Junior Member
I have 2 projects A & B,project A is a library project. B is a normal app project. B references A.

When I open a java file classB in project B, and click F3 on classA in the source of classB, where classA is a class in project A, eclipse opens classA.class in the new tab which contains the source lines including the comments line but it's readonly. I have to manually open classA.java for editing. This is verify annoying. It is never a problem in other IDEs.
I hope Eclipse open the classA.java directly in the editor.


Re: F3 opens the classB.class file instead of the classB.java file [message #1008041 is a reply to message #1007927] Fri, 08 February 2013 15:49 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
It looks like your project B refers to a compiled jar of A, not to the project A?
If you put project A on B's build path, it should work exactly as you expect.
Re: F3 opens the classB.class file instead of the classB.java file [message #1010036 is a reply to message #1007927] Sat, 16 February 2013 10:30 Go to previous messageGo to next message
techie pro is currently offline techie proFriend
Messages: 3
Registered: February 2012
Junior Member
Check the "Order and Export" tab under Build Path of the Project B.
The source folder of the Project B must be the at the top before Project A.

Let me know if that works. If it does not then , post a snapshot of your "Order and Export " Tab of your project B.
Re: F3 opens the classB.class file instead of the classB.java file [message #1039790 is a reply to message #1010036] Fri, 12 April 2013 15:41 Go to previous messageGo to next message
Florian F is currently offline Florian FFriend
Messages: 9
Registered: February 2011
Junior Member
I am alwas annoyed by this behavior.

I tried to put the projectA.jar at the very top of Order and Exports in project B, but when I press F3 or, worse, when I click on a stack trace in the console, it still opens the .class file.

It just doesn't make sense to me that Eclipse can identify the proper .java source file using the source attachment, can tell the source is in my workspace, can see that the relevant project A is currently open, but still doesn't think I might need to edit it.

I can avoid this by adding project A in project B's project dependencies (java build path, tab 'Projects'). But when I do that, all .class files of project A appear in project B's 'classes' folder and duplicate the classes in projectA.jar.

[Updated on: Fri, 12 April 2013 15:48]

Report message to a moderator

Re: F3 opens the classB.class file instead of the classB.java file [message #1040248 is a reply to message #1039790] Sat, 13 April 2013 08:41 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Florian F wrote on Fri, 12 April 2013 17:41

I can avoid this by adding project A in project B's project dependencies (java build path, tab 'Projects'). But when I do that, all .class files of project A appear in project B's 'classes' folder and duplicate the classes in projectA.jar.


Right, in order for source lookup to consider the workspace project A, you must define a dependency on the project, not the jar.

If this leads to copying class files to project B's classes folder then that is a bug.
Seeing your output folder named "classes" makes me think you could be using Maven here?
If that's the case please try to find out which tool (Eclipse or Maven) is causing which effect.

If you have a reproducing example please consider filing a bug.

thanks,
Stephan
Re: F3 opens the classB.class file instead of the classB.java file [message #1041585 is a reply to message #1040248] Mon, 15 April 2013 09:23 Go to previous message
Florian F is currently offline Florian FFriend
Messages: 9
Registered: February 2011
Junior Member
Hello, thanks for looking into my problem.

The output folder is defined in the Java Build Path, tab 'Source' as MyProject/WebRoot/WEB-INF/classes. Note that it is a web project. And it is MyEclipse.

I checked and it is not in this output folder that the .class files of ProjectA appear, but in the deployment folder under tomcat. This happens when ProjectA is in 'Java Build Path > Project'. Is there a way to avoid this?

Just to be sure, when you say I must define a dependency on the project, should I define the dependency under 'Project Dependency' or under 'Java Build Path > Projects'?

And if I should not define a dependency on the jar, how can I tell ProjectB which jar in ProjectA to use?

[Updated on: Mon, 15 April 2013 09:23]

Report message to a moderator

Previous Topic:How do I go from an empty OSGI bundle/plugin to extending Eclipse?
Next Topic:XML File generation
Goto Forum:
  


Current Time: Fri Apr 26 23:34:12 GMT 2024

Powered by FUDForum. Page generated in 0.03416 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top