I am using Eclipse Galileo for Java EE, and I want to configure JUnit to show me the source code when I try to navigate to its methods. I've tried attaching source to the JUnit library, but the library definition is not editable. I cannot even find where to configure the JUnit library in the preferences.
When I open the Add Library window and choose JUnit, I see a dialog where I can choose the JUnit version, but it shows that Source Location is "not found".
How can I configure Eclipse to find JUnit's source?
I downloaded the Eclipse SDK and checked the differences, and I finally got it to work.
Download this JAR into your eclipse/plugins directory.
Edit the file source.info in your eclipse/configuration/org.eclipse.equinox.source directory, and add the following line:
org.junit4.source,4.5.0.v20090423,plugins/org.junit4.source_4.5.0.v20090423.jar,-1,false
Open the file artifacts.xml in your eclipse directory, and add the following fragment:
<artifact classifier='osgi.bundle' id='org.junit4.source' version='4.5.0.v20090423'>
<properties size='2'>
<property name='artifact.size' value='128389'/>
<property name='download.size' value='128389'/>
</properties>
</artifact>
If Eclipse is already open, you'll need to restart it for the changes to be detected.
Note: For Eclipse 3.6 (Helios), you should use the updated JAR(s). See the comments by #Supressingfire and #Milo.
Note: on Eclipse 3.6(Helios), step 3 (artifacts.xml) is not necessary.
Tested on Ubuntu Eclipse 3.6:
Version: Helios Service Release 2
Build id: 20110218-0911
My eclipse version is 4.6.0, the only solution that has worked so far for me is to download the source file which named org.junit.source_4.12.0.v201504281640.jar from ftp://ftp.osuosl.org/pub/eclipse/eclipse/updates/4.6/R-4.6-201606061100/plugins/, then placed it into eclipse\plugins, afterwards restart eclipse then the source file has bound to the appropiate junit jar file automatically.
As mentioned in this thread, if you have downloaded the SDK version of Galileo, you have the sources of the main plugins.
For JUnit, this would be:
<pathTo>\eclipse-SDK-3.5-win32-x86_64\eclipse\plugins\org.junit4.source_4.5.0.v20090423.jar
You can try to add that as a source file in the Source tab of a JUnit launcher configuration and see if that solves your issue when you are debugging your JUnit test and are stepping through JUnit native methods.
(Note: I have the x64 version of eclipse Galileo, but I believe the file is the same for the x32 or for other platforms)
#Hosam Aly answer also works in Eclipse 4.3.1:
The jar to download is here
The text to append to eclipse\configuration\org.eclipse.equinox.source is
org.junit.source,4.11.0.v201303080030,plugins/org.junit.source_4.11.0.v201303080030.jar,-1,false
I did not need to change artifacts.xml
Related
I am getting below error while installing Findbugs into Netbeans 8.2:
"There were some problems while storing Establishing a connection …
Cause: Cannot resolve external reference to m2:/org:ow2:asm:asm-debug-all:5.0.2:jar"
I have tried uninstalling NetBeans 8.2 and removing anything associated with the installation to get a fresh install with no success there, and I have tried the latest version of NetBeans 11.3 which I found does not have Findbugs available. I need the plugin for a school project and no one there has been able to help me with this issue either. Any help would be greatly appreciated.
I am using a Windows 10 PC.
Thank you.
The reason of the error
The error happens because when you download the plugin, NetBeans also tries to download additional dependencies. The links where to download the jars from are written inside the nbm package.
For example, one of the dependencies is asm-debug-all-5.0.2.jar, and the link is:
http://repo1.maven.org/maven2/org/ow2/asm/asm-debug-all/5.0.2/asm-debug-all-5.0.2.jar.
The maven repository is no longer accessible using the HTTP link. You can read more about it here.
So basically, you could not install the plugin because the plugin is outdated and contains invalid links for downloading dependencies from maven repo.
Before solving the issue, consider using SpotBug instead because the FindBug is outdated and is no longer actively maintained, for more information, please, see here in another answer. Also, keep in mind that it works only with JDK8.
How to solve it?
To solve the issue, you need to fiddle around a bit with plugins.
You need two plugins FindBug Libs (org-netbeans-libs-findbugs.nbm) and FindBug Integration (org-netbeans-modules-findbugs.nbm). Download them using thees links:
https://updates.netbeans.org/netbeans/updates/8.2/uc/final/certified/82/extra/org-netbeans-modules-findbugs.nbm
https://updates.netbeans.org/netbeans/updates/8.2/uc/final/certified/82/extra/org-netbeans-libs-findbugs.nbm
Unzip org-netbeans-libs-findbugs.nbm manually as if it is a simple zip file.
Edit the files in org-netbeans-libs-findbugs\netbeans\modules\ext extracted folder. In every file, you need to change the link from http to https.
Edit manifest file org-netbeans-libs-findbugs\META-INF\MANIFEST.MF. You need to remove all lines that contain CRS checksum. After editing it should contains only these lines:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.2
Created-By: 1.8.0_45-b14 (Oracle Corporation)
Remover other two files in org-netbeans-libs-findbugs\META-INF (ORACLE_C.RSA and ORACLE_C.SF).
Zip it again.
After that, the file is ready for manually installing into Net Beans. Alternatively, you can download the file from here. I have already modified the plugin using the steps.
How to install and use it?
Got to Windows -> Plugins -> Downloaded -> Add Plugins
Manually add the modified org-netbeans-libs-findbugs.nbm file and click install.
Then add org-netbeans-modules-findbugs.nbm and click install.
When installing, it shows that it downloads the plugin, but actually, it downloads only dependencies. It can take some time.
After that, select your project in the project tree, make sure it was compiled before. Got to Source -> Inspect, choose FindBus in the Configuration.
After you click to inspect your report will be ready.
It works both on NetBeans 11.3 and 8.2. Make sure you are using JDK8 with NetBeans. I'm not sure it will work with the newest versions of JDK.
Here is an example with running it on 11.3 using JDK8 on some NetBeans module:
I have installed FindBugs plugin version 3.0.1 for Eclipse Mars. I am trying to get the FindSecBugs 1.4.1 plugin to work. I don't have internet access. I have the FindSecBugs jar. I am unsure of where to put the jar file and if anything else needs to be done.
Just put it anywhere on your filesystem, open Window->Preferences->Java->FindBugs->Plugins and misc. Settings and use "Add..." button there:
I am new to Netbeans and I am trying to install JUnit in the IDE. I have searched multiple places and can not find a clear answer. I am running Windows8 with the latest updates and Netbeans 8.0.2. I have downloaded the jar file for JUnit opened Tools => Plugins then Downloaded tab. I select the jar file but nothing happens. I have also tried to run the jar file from commandline and double clicked it and nothing happens. I am looking to expand my skills sets by practicing using JUnit so any help would be appreciated.
thank you.
It is installed by default.
To see that it is installed goto Tools -> Plugins -> Installed and search for JUnit. If it is not there, check Tools -> Plugins -> Available Plugins before trying your own download.
To use select any java file in the projects directory, right-click Tools -> Create/Update Tests. This will create a stub test file under Test Packages under your Project in the projects tab.
Select the project and right-click for Test to run all the tests or select any file and right-click for the Test File option.
I have not used Netbeans for many years now. However, a quick search shows that during the installation process, there is an option of installing JUnit along with Netbeans. The default option(checked) is Install JUnit.
If by any chance, the second option(Do not install JUnit) got checked, you may want to re-install Netbeans again.
For some reason I am still using the old 8.0.2 version of Netbeans, and I found out that the install script apparently installs the junit plugin, but not the junit libs. Downloading the following files and adding them as test libs helped:
junit-4.13.jar
hamcrest-core-1.3.jar
At the time of this writing, they could be found here: https://github.com/junit-team/junit4/wiki/Download-and-Install
I had the same issue and this is how I solved it,
First download the jar file for Junit from this link
Junit test jar
Then follow along as shown in the images
Right click on the Library section on your particular project
Click on the create button and name Junit(on your preference)->Ok
Then select the Library you created and then select Add Jar/folder
Then select the .jar file you downloaded before and select Add jar folder
Now you have setup the Junit library on netbeans
An eclipse plugin called JDTCommentsV2_1.0.9 does the following in eclipse:
I'm trying to add/edit some comments inside. e.g. add Run TestComment or just change one of the comments' name.
I have the .jar file and here's how it looks inside:
Question is which files should i edit and how.
Thank you
edit:
After following #greg449 and #Robin Green's instructions, I exported the jar file to eclipse, and edited the plugins.xml file. But if i export the files now as a jar, it doesn't work (nothing is changed in the menu). Finally i tried what #Robin Green said (Run -> Run As -> eclipse application) but there is no eclipse application under Run As. I got only Java Applet and Java Application. I'm wondering why. Might it be because i'm using ADT?
edit2:
I downloaded another version of eclipse (not ADT) and here i do have the Run As eclipse application bar". Can't i add it to ADT ?
edit3:
The picked answer works for eclipse JDT and not eclipse ADT.
It looks like you have a jar containing an existing Eclipse plugin so in your Eclipse you do File > Import and choose General > Existing Projects into Workspace and select the jar as the source.
Once you have the plugin project installed in your workspace you are going to have to work out how the plugin works by looking at the source and the plugin.xml.
Once you have modified the plugin use Export > Plug-in Development > Deployable plug-ins and fragments to build a new plugin jar.
Generally speaking you check out the source code from its source control repository or download it as an archive file from its website and then import it into Eclipse, same as any other project.
I've been trying to attach JUnit sources in my Eclipse Indigo. From within the IDE it doesn't work - there's a non-modifiable no source attachment (why?) . I tried following the advice in "How do I configure JUnit's Source in Eclipse?", with JUnit version 4.8.2, but that didn't work. It's possible I didn't follow the instructions there just right, but I don't see any indication of where I could have made a mistake.
What can I do?
You should download JUnit source jar manually and it put them to the plugin folder (don't forget eclipse -clean).
Download JUnit jars from here ftp://ftp.osuosl.org/pub/eclipse/eclipse/updates/3.7/R-3.7.1-201109091335/plugins/ (*junit*, source files and jdt).
This is not last version, but you can easily change it.