I am trying to write some code to use class from a downloaded java file. I saved them in the same folder and I can open the file with Eclipse. I noticed that there is a hollow "J" there, then I researched related problems online and knew that this is caused by the build path of files. Those methods told me to open the "properties" in "Project" section, but the icon is just grey and I cannot do anything with it!
How to solve this problem?
Eclipse does not automatically refresh changed content in the file system. You have to refresh the workspace whenever you edit/delete/add files directly in the file system. Right click on the project (or the subfolder) you want to refresh and choose 'refresh' (or F5).
Related
I have been using two separate IDE's for my coursework (jGRASP and Netbeans). Whenever I attempt to save a file in Netbeans, the file automatically saves as a "jGRASP Java file" instead (see picture below). When I open the project from file explorer it automatically opens jGRASP instead of Netbeans, even though I saved the project while using Netbeans. Is there a way to ensure that projects I work on in Netbeans do not save as jGRASP files? When submitting my assignments, I have been instructed to ensure they are Netbeans projects (not any other IDE).
What it looks like to me, is the file association for .java files in your computer are set to use jGRASP, you should be able to just change the association in your PC and it would be fine. They are just .java files so if you submit them it should be ok, but you can change it.
https://support.microsoft.com/en-us/windows/change-default-programs-in-windows-10-e5d82cad-17d1-c53b-3505-f10a32e1894d
To explain a bit more, there is nothing in the file itself that indicates which application saved it. A source file is just plain text, and what you see when editing it is all that is there.
I have a problem with my war.xml file in that it isn't picking up my class files correctly for spring.
The line that is wrong is:
<dir sourceOnDisk="C:\myApp\src\main\java" targetInArchive="/WEB-INF/classes"/>
I need:
<dir sourceOnDisk="C:\myApp\bin" targetInArchive="/WEB-INF/classes"/>
Now, I can change the file manually (from src\main\java to bin), and it works correctly for a while, but every now and again something decides my war.xml file needs to be rebuilt, and things then break again.
I added my application by dragging my project from eclipse's Project Explorer tab to my liberty profile server instance within eclipse's Servers tab.
Where is the menu option within eclipse to change this?
To automatically map your bin folder to the WEB-INF/classes folder, select your project on the Project Explorer, right click it and select Java Build Path. In this property page on the Source tab, you can add, edit or remove the source folder, and also modify the default output folder. In this case you may only need to modify the output folder, to something similar to (project-name)/bin
Regarding the *war.xml file located at (server-dir)/apps, this will be refreshed each time you modify your project in eclipse, if when doing it, you have your server started and with automatic publish enabled. Usually you don't modify this file yourself, but you can read more about it here: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.wlp.nd.doc/ae/rwlp_loose_applications.html?cp=SSAW57_8.5.5%2F1-14-1-10
Turns out the correct place to change things is in the Deployment Assembly option when you right click on your project...
I'm posting this query after doing lots of googling and trying out different options for last few days. Is there an easy way to attach source in Eclipse? is the closest answer I found to my question.
From above post, I tried all solutions but each time Eclipse is opening .class file instead of .java file.
Eclipse Details:
Kepler Service Release 2
Build id:20140224-0627
Please let me know if this is a bug with Eclipse or if I am missing something.
If you are using Maven, try this:
Double click on your project in eclipse -> Maven -> Enable Workspace Resolution
This is most likely because Eclipse actually use the class file for declaring the item you have requested the declaration for, and not the source file you think it should be using.
The typical reason for this is if you have a jar file containing previously compiled classes on your build path before (or instead) of the project containing the source you want. This is very rarely desirable as it can take quite a while to discover that your edits do not take effect.
Examine your build path carefully and ensure it is as you want it to be.
Maven is likely supplying a Classpath Container to your project, and generating entries for the Java Build Path based on the pom.xml contents (the JRE System Library is another example of this). Its entries will not have source attachment unless the container decides it will, which is why the Installed JREs preference page offers to let you set Source Attachments. If the pom.xml has something like that, see if you can use it. If not, see if you can configure the Maven container from its context menu. Otherwise, you may simply be stuck.
I had this same problem: when I pressed F3 or tried to open Declaration (after right click) for any element, it took me to the bytecode .class file.
My solution:
I went to the project in Project Explorer:
right click on project name->Properties
Then in Porject Properties window,
Java Build Path->"Order and Export" tab
There I selected the folder with the .java files (source code), which was below the folder having the .class files -in my case "JRE System Library [java-11-openjdk-amd64]", and pressed 'Top' button on the right frame. Then the folder with source files moved to the top.
Finally, pressed "Apply and Close" button.
That solved my problem forever and ever.
The folder
I installed a plug-in which allows me to download the sources for a maven project.
I'm not by my develop machine right now, but I think it was this:
http://marketplace.eclipse.org/content/m2e-dynamic-sources-lookup#.U8gjGWIaySM
With this, you can select a project an have maven download the sources and make then available when you navigate the code in Eclipse. All without "leaving" Eclipse.
Check into your project modules the Java Build Path, look inside the Source tab and verify if you have "Allow output folders for source folders" checkbox flagged; in this case you just need to uncheck it and you will be able to see again the right source from java files.
This is related to the Call Hierarchy in Eclipse IDE.
If you are in a situation, where you're seeing duplicate methods inside the call hierarchy showing Members calling 'myMethod(...)', double-clicking on one of the listed methods may open the .class file instead of the .java file.
When this happens, the solution is to set the search scope in the call hierarchy to Project instead of Workspace.
After setting the search scope, you won't be seeing duplicate methods listed in the call hierarchy, and double-clicking on the listed methods will only open the .java files.
(Using Eclipse DevStyle Dark Theme)
So, when I double click a file in windows explorer, Intellij fires up, but instead of just showing me the file I want to see, shows up the following message:
I think I get what it means: it means this given .java file isn't associated with an Intellij project.
That's actually true, but even so I'd like to be able to open the file and see it with syntax highlighting and such.
How to overcome this problem?
Thanks
It's a known limitation which we plan to address in the future versions to allow opening and editing individual files without project context.
Please watch/vote the related issue.
I don't think you can'tcan by default. I'm assuming you are opening downloaded files or such. What I would is create a project (Scrapbook for example is a good name) on desktop and I would put/download the file I want to see in the corresponding src folder. That way when I'm clicking it would open properly.
Most of the syntax highlight and such goodness of idea comes from a proper project setup (proper JDK paths, libraries, etc).
I want to be able to right click an item within the 'Projects' or 'Files' window, and either have an 'open in file system' option, or 'copy absolute path to this file'.
Is there a plugin or a hidden option within Netbeans that will allow me to achieve this?
I just need an easier way to get to the folder within Windows Explorer without having to spend the time navigating there.
I'm open to making a small plugin myself if it'll make it happen?
With Netbeans 8 you can use:
Alt+Shift+L
It's defined under Options->Keymap as Copy File Path(s)
Somewhat related : netbeans - how to view file full path in window title (or somewhere else)?
You can use either of following :
Use Alt+Shift+O to open files by name (which shows the path and the
project)
Hit Ctrl+Shift+1 while in the editor to highlight the file in the
Projects View
There is a community contributed plugin on NetBeans bug-tracking system that can implement the feature. I have verified that the plugin works well with NetBeans 6.9.1. Once installed, you could copy the path of a file (or files under a folder node) via Edit/Copy Path menu.
Plugin "Path Tools" # plugins.netbeans.org
I use this plugin which lets you copy the full path of a file to the clipboard - https://github.com/kinkadzs/QuickOpener-NetBeans
The information you search can be accessed trough the file properties.
In the Projects window, right click on a file, select 'Properties', the file path is under the 'All Files' line.
You can also press Alt-Shift-O while the file is selected in the Projects view or the file you're editing.