Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Open Declaration opens class file
Open Declaration opens class file [message #511789] Tue, 02 February 2010 21:25 Go to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: January 2010
Junior Member
How do I define the open Declaration to use the available source file instead of the class file?
Re: Open Declaration opens class file [message #511879 is a reply to message #511789] Wed, 03 February 2010 10:19 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
paul_hartwig@irco.com wrote:
> How do I define the open Declaration to use the available source file
> instead of the class file?
You need to attach the source to the JAR.

Dani
Re: Open Declaration opens class file [message #652549 is a reply to message #511789] Fri, 04 February 2011 14:03 Go to previous messageGo to next message
Florian F is currently offline Florian FFriend
Messages: 9
Registered: February 2011
Junior Member
It doesn't work for me. Not the way I expect it.

OK, I have configured the source directory for my jar (in Project Properties>Java build path>Libraries). What happens is that when I press F3 on a class MyClass, It displays the correct source, but the file tab says "MyClass.class" and not "MyClass.java". And the file is readonly.

If I want to modify it, I have to re-open the same source file with ctrl-shift-T. I then have the same file open twice, one under ".class" and one ".java". I only can edit in the ".java" tab.

Why can't it open "MyClass.java" straight away?

Note that I have the same problem when zooming from a stack trace.

Can anybody enlighten me?

[Updated on: Mon, 07 February 2011 11:18]

Report message to a moderator

Re: Open Declaration opens class file [message #652575 is a reply to message #652549] Fri, 04 February 2011 14:31 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 04.02.2011 15:03, Florian F wrote:
> It doesn't work for me. Not the way I expect it.
>
> OK, I have configured the source directory for my jar (in Pro. What
> happens is that when I press F3 on a class MyClass, It displays the
> correct source, but the file tab says "MyClass.class" and not
> "MyClass.java". And the file is readonly.
>
> If I want to modify it, I have to re-open the same source file with
> ctrl-shift-T. I then have the same file open twice, one under
> ".class" and one ".java". I only can edit in the ".java" tab.
>
> Why can't it open "MyClass.java" straight away?
Because you attached the source to the JAR that's on the Java build
path. If you have the source and also the legal permission to modify
that source then simply put the source on the build path and not the JAR.

Dani
>
> Note that I have the same problem when zooming from a stack trace.
>
> Can anybody enlighten me?
Re: Open Declaration opens class file [message #652608 is a reply to message #652575] Fri, 04 February 2011 17:07 Go to previous messageGo to next message
Florian F is currently offline Florian FFriend
Messages: 9
Registered: February 2011
Junior Member
Thanks, it would probably work, but it is not the same.

I don't want the library's .class files to end up in my classes directory. I deploy my application from that classes directory.

The way I work is that most of the time the library remains untouched. It is a common base shared by many projects. But now and then I need to update something in the library. When I do so, I make my changes and recompile, which automatically regenerates the .jar file. I want to keep the library classes in the .jar and the application classes in my classes directory.

The question really was, is there any reason for Eclipse not to open the .java file when that file is part of a project in my workspace?
Re: Open Declaration opens class file [message #664222 is a reply to message #652575] Thu, 07 April 2011 21:46 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: April 2011
Junior Member
I have done this several times. I have 2 very similar projects open. One opens the .java file. One opens the .class file. The src/ is on the source tab, libraries on the libraries tab. It's all the same stuff both projects. I've added it and removed it and re-added things selectively to figure out what is going on. Project > Properties > Java Build Path. I just want the plain old java src file to open so I can see code AND edit, and also to view call Hierarchy. Is there another properties area to edit?

20110218-0911
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Re: Open Declaration opens class file [message #664378 is a reply to message #664222] Fri, 08 April 2011 15:05 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
On 4/7/11 5:46 PM, bvitiello@egenera.com wrote:
> I have done this several times. I have 2 very similar projects open. One
> opens the .java file. One opens the .class file. The src/ is on the
> source tab, libraries on the libraries tab. It's all the same stuff both
> projects. I've added it and removed it and re-added things selectively
> to figure out what is going on. Project > Properties > Java Build Path.
> I just want the plain old java src file to open so I can see code AND
> edit, and also to view call Hierarchy. Is there another properties area
> to edit?

The class(es) that you're trying to open the declarations for, are they
part of a JAR? If so, you probably set the source location for that JAR
in the project that works correctly but didn't do that for the project
that is only showing the class files.

Eric
Re: Open Declaration opens class file [message #664565 is a reply to message #664378] Mon, 11 April 2011 08:09 Go to previous messageGo to next message
Florian F is currently offline Florian FFriend
Messages: 9
Registered: February 2011
Junior Member
If the source location is not configured, you don't see the source. That is normal.

The problem is that sometimes, when you zoom on a type, it displays the source, but the tab says ".class". And you cannot edit your source. The same happens when you click on a stack trace in the console.

Sometimes it works, it opens the .java and it allows to edit, but sometimes it opens the .class and it is read-only. It is not clear when it works and when it doesn't. I would expect that if the source is part of a project configured in eclipse, it should open the .java file. But it doesn't always work.

Re: Open Declaration opens class file [message #664718 is a reply to message #664378] Mon, 11 April 2011 17:05 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: April 2011
Junior Member
There are no Sources attached to any jar on both projects. If I do that, what I end up with is a java file with code that I cannot edit. As a matter of fact, now I removed all the jars from the broken project. I left the source folder with all the java files on the build path by using the Source tab in the properties and I have that one at the top on the Order and Export. So I guess the question is why doesn't it use that? When I have time I will start removing items from the project that works build path, one by one, and see what happens. [Although I'm skeptical it will ever get back to a working state again if I do this]
Re: Open Declaration opens class file [message #664729 is a reply to message #664718] Mon, 11 April 2011 17:52 Go to previous message
No real name is currently offline No real nameFriend
Messages: 3
Registered: April 2011
Junior Member
I just removed the source folder and added a higher level source folder. Then I added all the java jre/lib/*.jar to my path. Then I closed and reopened the project. Now It seems to be working. Thanks. Wink
Previous Topic:Eclipse Changing Preferences
Next Topic:Eclipse with JDK7
Goto Forum:
  


Current Time: Sat Apr 20 01:24:55 GMT 2024

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

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

Back to the top