files missing from src folder (Jboss/eclipse) - java

In JBoss (Eclipse) I am having a problem with my src files showing up in the src folder in the package explorer. As you can see from the picture on the left there is nothing in the folder for test, and no java files under main, but webapp. For example though I went to where the files are stored and show you that there are infact tons of files inside of the test folder. Any idea how to get them to show back up in the Package explorer in eclipse?
edit: srry forgot pic

In Eclipse, make sure the filter is not turned on to hide types of files you're looking for. Under Package Explorer, click the small down arrow to the top right of your listed projects. In that list, select Filters... then make sure you're not filtering out the files you're looking for. Checked items are hidden from your view.
Otherwise, the picture you've said you posted, I can't see. So I'm sort of guessing what the problem really is here.
EDIT: OK, I see the picture now.

Java files are shown under src/main/java at the top of the package explorer. If you right-click the project name, select Build Path -> Configure Build Path... and select the Source tab, you can see which folders have been designated as containing java source files.
Files in those folders will have been filtered out from the main "plain" type folders. Eclipse treats stuff marked in "source" folders differently. Mainly, it will attempt to compile java files it finds there.

Solved it, It was just that I was in regular Java perspective instead of the JBoss perspective. Honest silly mistake. Thanks for the replies though!

Related

Java Eclipse Build Path

Hi i write a Java Swing GUI that includes alot of .jar files.
I have add alot of .jar files to my Buildpath. If now my friend trys to run the programm he got my Buildpath and they are wrong on his pc.
Is there a possible way to set the Buildpath so my friend don't have to set them again?
for example at the moment one buildpath is like this:
home/usr/bonzai/oad/xxx.jar
my programm that is executed is in the folder bonzai. so i want to set the path like this:
./oad/xxx.jar
So the programm knows go into the folder oad, that is in the same folder, then take xxx.jar.
Hope you understand what i want to do :-)
mfg
Christoph
I had this problem with using a project on Windows and Linux.
Go to Window->Preferences->Java->Build Path->Classpath Variables
Click "New", pick a name, like MY_PROJECT, and point to the project folder.
When you include jar files, you do it a different way.
Project Properties->Java Build Path->Libraries (where you add jar files)
To add, click "Add Variable"
Select the MY_PROJECT variable you made and click "Extend". Find the resource and add it to your project.
Now when anyone wants to use your project, they just have to do step 1 and 2. and point the MY_PROJECT classpath variable to where ever the folder is. It can be anywhere. As long as the structure inside is the same, everything works.
This is how I share .project files with GIT. You can clone the project anywhere but everything works.

Eclipse Java Project - Open Declaration always opens class file instead of .java

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)

I entirely screwed up my build path/project explorer

All of my "folders" were being showed as packages and so on one of my packages, I hit "use as source folder" which converted it into a folder but seems to have make all other folders fall inside that folder...Is there any way to revert this change? After that I hit exclude from build path and it did some other weird thing. I'm not experienced with eclipse and probably screwed everything up.
ScreenShot :
http://i.gyazo.com/4846d8c628e3e6a9973b557884c0a74f.png
Right click on src folder->Build Path->Remove from Build Path. Then again right click on src folder->Build Path->Use as source folder.

Why do maven projects have a src folder which has two empty sub-folders (main and test)

I am new to the java world. I created a simple java (maven) project and I see the packages and everything works perfectly. However I do see a src with two empty main and test folders. Any idea why?
EDIT: Adding more information to the answer
The answer below is perfect. However on tinkering a little more I found a more compelling reason why it is shown like that in eclipse.
If the folder is in "Java build path" then those folders will be shown above in the specialized view. So you can create any folder and once you add that folder to the "Java build path" the view for that folder changes. Same if you remove an existing folder from the "Java build path" then it seems to go back as a normal tree view in the bottom.
Folder are not empty. Look where your App.java is: src/main/java/com/nuance/spring
Eclipse hide you content on this place because that are special folders with special view above.
If you have other folders that aren't special, for example WEB-INF then you'll see it there.
they actually aren't empty if you look at the directory out side of your editor (looks like eclipse). eclipse has created source folders for you which can be seen above. src/main/java and src/test/java.
so if you take a look at the folder in your operating systems explorer you should see files in there

Attach the Source in Eclipse of a jar

I added a Student.jar into my Build Path in my eclipse like this-
Right click on the project->BuildPath->Configure Build
Path->Libraries->Add External Jars
There is one class named StudentTest in Student.jar file. When I was debugging my code in eclipse, I stepped into that StudentTest class in the Student.jar.
And after that eclipse shows me like this-
The JAR file S:\some_location\Student.jar has no source attachment.
You can attach the source by clicking Attach Source below
Now I am not sure how should I attach the source in my eclipse. And from where? Can anyone provide me step by step what I need to do.
Update:-
I tried unzipping the Student.jar and I got Student folder. And after that I tried pointing the source to Student folder But still I am not able to see the class properly so that I can debug it properly, it shows the same above behavior.
Use Java Source Attacher !
It does what eclipse should do - a right click context menu that says "Attach Java Source.
It automatically downloads the source for you and attaches it. I've only hit a couple libraries it doesn't know about and when that happens it lets you contribute the url back to the community so no one else will have a problem with that library.
Eclipse is showing no source found because there is no source available . Your jar only has the compiled classes.
You need to import the project from jar and add the Project as dependency .
Other option is to go to the
Go to Properties (for the Project) -> Java Build Path -> Libraries , select your jar file and click on the source , there will be option to attach the source and Javadocs.
A .jar file usually only contains the .class files, not the .java files they were compiled from. That's why eclipse is telling you it doesn't know the source code of that class.
"Attaching" the source to a JAR means telling eclipse where the source code can be found. Of course, if you don't know yourself, that feature is of little help. Of course, you could try googling for the source code (or check wherever you got the JAR file from).
That said, you don't necessarily need the source to debug.
This worked for me for Eclipse-Luna:
Right Click on the *.jar in the Referenced Libraries folder under your project, then click on Properties
Use the Java Source Attachment page to point to the Workspace location or the External location to the source code of that jar.
Go back in to where you added the jar. I believe its the libraries tab, I don't have Eclipse open but that sounds right. to the left of the jar file you added there should be an arrow pointing right, click that and 3 or 4 options expand, one of them being the source file of the library. Click on that and click edit(I think you can also double click it) then locate the file or folder on your hard disk, you probably have to click apply or okay and you're good to go, same with javadoc and i think the last one is native libraries. I don't pay much attention when I'm in there anymore if you couldn't tell. That's what you were asking, right?
I Know it is pretty late but it will be helpful for the other user, as we can do Job using three ways... as below 1)1. Atttach your source code using i.e, Right click on the project then properties --> Java build path--> attach your source in the source tab or you can remove jar file and attach the source in the libraries tab
2. Using eclipse source Analyzer In the eclipse market you can download the plugin java source analyzer which is used to attach the open source jar file's source code. we can achieve it after installing the plugin, by right click on the open source jar and select the attach source option.
3. Using Jadclipse in eclipse you can do it last not the least, you can achieve the decompile your code using this plugin. it is similar way you can download the plugin from the eclipse market place and install in your eclipse.
in jadclipse view you can see your .class file to decomplile source format note here you cannot see the comment and hidden things I think in your scenario you can use the option one and option three, I prefer option three only if i want to the source code not for the debug the code. else i ll code the option 1, as i have the source already available with.
Simply import the package of the required source class in your code from jar.
You can find jar's sub packages in
Eclipse -- YourProject --> Referenced libraries --> yourJars --> Packages --> Clases
Like-- I was troubling with the mysql connector jar issue
"the source attachment does not contain the source"
by giving the path of source folder it display this statement
The source attachment does not contain the source for the file StatementImpl.class
Then I just import the package of mysql connector jar which contain the required class:
import com.mysql.jdbc.*;
Then program is working fine.
I faced the same issue and solved using the below steps. Go to Windows->preferences->Editors->File Associations
Here click on Add
then type .class
click on OK
again click on Add
then type .classwithoughtsource
click on OK
Now you will be able to see JadClipse option under Java section in Windows->Preferences
Please provide the path of jad.exe file as shown below.
Path for Decompiler-C:\Users\ahr\Documents\eclipse-jee-galileo-SR2-win32\jad.exe
Directory for temporary Files-C:\Users\ahr.net.sf.jadclipse
click on Apply
Now you should be able to see the classfiles in proper format.
It is quite possible, just go to the jar in the Build Path and choose to attach a source just like follow.
Download JDEclipse from http://java-decompiler.github.io/
Follow the installation steps
If you still didn't find the source, right click on the jar file and select "Attach Library Source" option from the project folder, as you can see below.
I am using project is not Spring or spring boot based application.
I have multiple subprojects and they are nested one within another.
The answers shown here supports on first level of subproject.
If I added another sub project for source code attachement, it is not allowing me saying folder already exists error.
Looks like eclipse is out dated IDE. I am using the latest version of Eclipse version 2015-2019.
It is killing all my time.
My intension is run the application in debug mode navigate through the sub projects which are added as external dependencies (non modifiable).
I have faced same problem and resolved it by using following scenario.
First we have to determine which jar file's source code we want along with version number. For Example "Spring Core" » "4.0.6.RELEASE"
open https://mvnrepository.com/ and search file with name "Spring Core" » "4.0.6.RELEASE".
Now Maven repository will show the the details of that jar file.
In that details there is one option "View All" just click on that.
Then we will navigate to URL "https://repo1.maven.org/maven2/org/springframework/spring-core/4.0.6.RELEASE/".
there so many options so select and download "spring-core-4.0.6.RELEASE-sources.jar" in our our system and attach same jar file as a source attachment in eclipse.
Try removing the breakpoints. :)

Categories

Resources