i just imported a Jackson's annotation library and imported it into my java application project in eclipse. However, after importing, the package doesn't contain any java files.
If I open the .jar file using a .zip extractor, all the java files are present.
Anyone knows how to rectify this?
Thanks already.
Screenshot : Empty
You need to add the binary jars (jar which has the class files), and not the source jar files.
If you add the source jar files and imported to your buildpath eclipse wont show any java files.
Instead first add the jar containing the class files, and then you can attach the source jar to the binary.
Related
I have a jar file which is a bunch of .class files(Java). I need to use some of the classes inside of the jar file into my intellij project. I followed these instructions:
Adding class/jar file to IntelliJ IDEA
The jar file did successfully link into the project as an external library. But, I am not able to access any of it's classes. Nor am I able to import any files from it. Can some one help me out ?
I created a new project in Eclipse in which I want to use the JTS library.
I imported the library during the creation of the project but I can't find the classes in the package explorer.
Since I am not experienced in Java and Eclipse, I'll explain what I did from the start.
I download the JTS library from GitHub: https://github.com/locationtech/jts
I create jts-core.jar using jar in the command line. I place it in workspace/Libraries
In Eclipse I create a new project in workspace/Projects/JTS-test. In the "build settings" I go to "Libraries" and "Add external JARs..." and select my jar.
This is what my package explorer in Eclipse looks like after step 3 :
However, when I browse in jts-core.jar outside Eclipse, org/locationtech/jts/algorithm/ is full of .java files and contains directories themselves containing other .java files.
What did I do wrong?
The JAR file referenced as a library must contain the *.class files (bytecode). In the JAR, the *.java files (source code) are only to see the source code and the Javadoc, but are not required.
Before jar, you missed compiling the *.java files (javac). Instead of creating a JAR yourself, you can download a ZIP file with all required JARs from the release page of the jts project. This ZIP file contains also the JARs that are required by jts.
Alternatively, you can copy the *.java files into the source folder (src by default) of your project or create add a new source folder for these *.java files. In contrast to classes in JARs, *.java files in source folders can be edited.
this is the API i want to use: https://labs.micromata.de/projects/jak/quickstart.html
i tried to download and unzip the files (including JAXB) but i have no idea what to do with them. how do i add it to my project?
i searched for how to add API/library but all results told me to import the jar file. did not find any jar file. the unzip folder just looks like a regular project folder. i also tried to export that folder into a jar file, it did not solve the problem, tried to copy and paste the folder into my project, also did not help.
in the doc it says:
Download the Java API for KML JAR at GitHub and add the JAR to your
classpath.
If there are any dependencies, resolve them and add JAXB to
your classpath, too. Version 2.1.xx should be fine.
to add what JAR? i'm really confused
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).
I have a Android project with some classes that I would like to compress to a JAR.
I create the JAR by right clicking my project - export - JAR - and the JAR gets created without any warnings.
I can access all classes from the JAR in my code but when I try to build the project get this exception :
java.lang.NoClassDefFoundError: name.of.class.in.package
Does anyone know what resources should be exported with the JAR? The options you get is
.class path
.prject
AndroidManifest.xml
proguard.cfg
project.properties
Right now I have included all of the above.
Making the JAR into a library project is not an option. And just to make it clear I don't have anything in the RES folder of my JAR project.
Open the project properties -> Java Build Path -> Order and Export and check item Android Dependencies are checked to be exported to the result APK.
And if .jar exist in Library tab under Android Dependencies item.
If you have .jar in the "libs" folder it should be included by default.
Just add your JAR to classpath or build your project with Maven and include dependencies
Try generating the jar in a different way. Basically jar is a zipped file of all class files with an extension of .jar.
Select all your class files that needs to be included in a jar file.
Right click and send to compressed (Zip File).
you will have a zipped file which will contain all the class files.
Rename this zipped file with having an extension .jar
Now include this jar file into your project whichever you want to use.
Or if you want to zip all the files by a different method then make sure all the files are zipped together without a folder. So when you unzip the files you should get all the files without contained in a folder.
It looks similar with this topic. Follow the very clear instructions written by Russ Bateman.