Search files by text in Maven Dependencies folder in Eclipse - java

I have a Java Maven project in Eclipse so all the Maven artifact jar files are listed in the "Maven Dependencies" package (folder?) in the Project Explorer. I would like to do a simple text search inside the *.class files inside the jars the same way I do a file containing text search. I can't use *.class directly in File name patterns field in Eclipse File search and if I use *.jar that will return binary results.
Was actually a bit surprised not to find answer to this so maybe I am missing something?

If you want to search for some text in some jar file, you need to select Java Search Tab. Press CTRL+H to see the screen bellow.
Note that I'm searching in Application libraries as well.
In the image bellow you can see the result of my search.
And finally, the reference in code inside of jar file.
I hope it helps you.

Related

IntelliJ: Hide .class files in file search in Maven Java project

I am working on a Maven Java project using the latest version of IntelliJ CE. I want to be able to view the source code of my Maven dependencies using the IDE's file search tool (ie, ⌘⇧O). However, I am getting both the .java and the .class files for each of the Java class names of a given dependency. Ideally, I only get results for the .java files (source code) instead of the .class files (bytecode). The .class files come from the dependency's JAR file, while the .java file comes from the dependency's sources-JAR file.
Is there any existing way to accomplish this? Thank you.
As answered by Bastien Jansen in the comments, the answer was to use Navigate Class (⌘O) instead of Navigate File (⌘⇧O).

How does one export and then import an exact copy of a java project jar?

I have tried various things starting with Java Maven project to get a jar which when imported looks exactly like the original but I have found that I can't for example get the src/main/resources folder to appear in the imported project. The goal is simple: so that on the new machine for example that the project can be run and worked on just like the original. Not sure what I am missing. I have tried importing existing project from archive which seems like it should work. On the original machine I select all files and folders but this still leaves out some things. I have tried to create an empty folder in Eclipse but this can't be done and various permutations.
A jar file usually contains compiled code and whatever else you drop in there which in turn enables you to run the code.
An eclipse, maven, intellij, ... project structure may be completely different. In the end a transformation will happen from that project structure to the jar content structure. In the case of Maven this will not be the same as the project structure.
The intent of a jar is running the compiled code, an intent of a project structure is to edit the source code.
If you want to copy an eclipse workspace to work on then do so. Copy the workspace folder.
user392486 basically showed what to do. The key is to export the file not as a jar but as a zip and the import it as an existing project which has an archive option. that works just as one would want, an identical project. how i could not already know this is beyond me...

Including external jars permanently in NetBeans

I'm building a Java Swing Application. This project requires a jar file called JCalender. I've added this to Libraries folder and everything works fine on my computer in NetBeans. But when i open the same project in my friends NetBeans, it doesn't recognizes this library. I've to manually select the file placed inside the projects dist/lib folder. How to avoid this? please help!
But when i open the same project in my friends NetBeans, it doesn't
recognizes this library. I've to manually select the file placed
inside the projects dist/lib folder. How to avoid this?
You can't avoid this because it's not a problem actually. To compile and run a project you need to have access to the external libraries involved in the development, so if you open your NetBeans project in a different computer than yours you will definitely need to resolve the reference to the external libraries. There's no way for the IDE to do it automatically as far as I know.
Can't i give the relative path to the lib folder for that specific
library somewhere in project properties?
You could just give it a try. IMHO if the real goal is to share a project with other developers then I'd change the strategy. I'd create a Library (Tools -> Libraries) and tell my mates to create the very same library including the JCalendar JAR files in the library's classpath. I'd include this library in the project properties and finally I'd use a versioning tool like Git or SVN to share the project.
By doing this your mates still need a copy of the JAR file wrapped in a NetBeans Library, but the project properties won't point to a fixed/relative path looking for a JAR file but wil include a reference to a given Library. The Library itself will resolve the dependency to the JAR file. If you take a look to the project.properties file you'll see something like this:
javac.classpath=\
${file.reference.jcalendar-1.4.jar}
But if you as I've suggested then you'll see something like this:
javac.classpath=\
${libs.JCalendar.classpath}
Here libs.JCalendar.classpath will resolve the dependency so your mates can have the actual JAR file located in whatever folder they like and the project should compile just fine.
Another option is using Maven to manage the projects dependencies but honestly I'm not a Maven expert so I can't help you in this path.
You need to do a "clean and build" and your jar will be in the dist folder. It will include the external jars
You can read more about it here
I think your problem is due to you are providing absolute path of jar file.
while choosing jar on write side of filechooser there is option of
Relative path and Absolute path there you should click on Absolute path.
i am new to java , but anyway , i have faced the same problem and found a solution for my project
If you are in Netbeans , its would be very easy for you
Let you project name is ABC and all your dependent jar file is under the
the folder MyResourceCollection
now we need to permanently import all jars under this folder ,
So from Netbeans ,
right click on your project name
go to properties
go to library
in the library page , check the "libraries folder" label
you can find a browse button at the right side of the label
click browse and select the MyResourceCollection folder
a new window will come , just press Next-->Next--->Finish
all is done , now check yourself by moving the folder into different location

How to add pdf files to NetBeans project?

I'd like to be able to open pdf files in a NetBeans project like this for a help menu but I don't see a way to add the pdf files to the project in a way that they will become part of the distribution. The application needs to be able to find the pdf files. I thought there might be an option to add the files to the project resources but this doesn't seem to be an option.
If you have a resource folder in your project then just copy it in there and then clean and build
or right-click on the folder and create a package
folder called "documents". Put your pdf in there and clean-and-build.

How do I create a jar distributable for javadocs?

I've created an API that I release as a JAR file. It's proprietary so I had to strip the source files out of it.
I currently include a separate /doc folder which contains the output of Eclipse's export-to-javadoc wizard. Not bad, but I'd like to go one step further.
I'd like to distribute the javadocs as a jar file that can be easily dropped into a future project which includes the jar file for my API. I know I've seen it done this way several times with other distributions I've used, but I haven't had any luck searching.
End goal is to allow future developers to have easy access to hover over comments and things of that nature.
Thanks!
It seems it is enough to package the doc folder containing the eclipse generated documentation as a jar file. Then if you want to use that jar as javadocs of the actual jar containing the compiled .class files, you assign the javadoc jar with the "Javadoc in archive" in Eclipse and set the Path within archive as doc. It seems Eclipse looks for index.html and package-list entries in the doc folder.
Also using maven-javadoc-plugin may an easy way to do this. See the link below:
http://www.avajava.com/tutorials/lessons/how-do-i-generate-and-deploy-a-javadoc-jar-file-for-my-project.html
If your end goal is just for the future developers to be able to view your javadoc instructions when they are using your classes or methods, in Eclipse you can have option to export java source files when you export your jar library as shown in the image below:
This also allows developers to step in and view your codes while debugging.

Categories