Eclipse not recognizing class after import of jar file - java

I have tried creating new projects. Removing and adding the jar file. Nothing is getting this thing to recognize it. I don't know if I am adding this correctly or not. Could someone please direct me, thanks.
EDIT: After some research using the help from the comments, it seems the problem is that the jar file only works if I am using a default package. I obviously don't want to use the default package so how can I change the Jar to fix this?

I don't know if this is a workaround or fix. I had to exclude the folders from my build path to use the jar file that had a default package. I did figure out how to deconstruct/reconstruct but for future reasons, I would not want to do this everytime someone hands me a file using the default pkg. So here is a screenshot of a working setup:
Please click it if it is not big enough for you. The summ/wint folders are excluded and I am able to use a class from the jar file without editing the jar file.
Money dd = new Dollar();
Thanks for all the comments.

Related

Gradle not building classname correctly

So I had a class named 'Helloworld' and have built the project with Gradle once after that I decided to rename the class into 'HelloWorld', and for some reason when I build it again and check inside the jar file I still have 'Helloworld.class' which is causing me problems as I need the exact class name.
I tried deleting the .gradle/caches but it didn't work.
I'm not really sure what files I should post to check if something is wrong so if someone comments I will edit the post.
If I were you, I'd just recreate the project altogether. Otherwise, are you able to rename the .class file that's causing you problems?

How to enable Yandex Translate API?

this may sound like a noob question, but it is a big problem for me. I have a file called yandex-translator-java-api-master.zip, and I tried adding that as an external JAR to my eclipse project, but the code wouldn't work; It wouldn't let me import.
This error comes up when i try to import "Translate"
Translate cannot be resolved
6 quick fixes available:
Create class, create constant, fix proj. setup...etc, etc.
How do i use this??? Where is the .jar i am supposed to import?
zip archive is not the same thing as jar. First, extract jar from zip archive and then add it as dependency. Then you'll be able to import.
UPD:
looking closely, I suppose you downloaded that archive from GitHub (or another VCS) and it's just sources of a library. You can not add it as a dependency, but you can, for example, just paste this code in your project's /src/main/. This is an easy solution. If you want to make things the right way, you can
a) Search for a compiled library
b) Create a module from downloaded sources and add it as dependency
Download this file:
And established it as a library.
Instruction is in this answer.

Already imported the jar files in netbeans but my source cannot find the library

I already imported the jar files in netbeans but my main java file still cannot find the methods. I am using netbeans 7.3.1 on Mac. Does anyone know how make it work?
Thank you,
I also had problem with importing classes from imported jar. It was so damn annoying...
There are couple solutions # web, (clear cache in user's AppData. or make sure to add jar's properly - by using "Add Jar/Folder..." option) but none of them worked for me.
What worked was new project and importing THE SAME (that's sad) jar files into it. So I had 2 project with exactly the same contents, but only one of them was working (compiling).
EDIT:
However, your problem is not related to mine. Root cause of your issue is the jar itself.
It contains class files in default package that is making them impossible to import.
Read here how to import class from default (unnamed) package.
hey guyes just keep your .jar files in the "C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext" it will work definitely.I have tried all the other options but i finally copied my .jar files in above path and it worked.

Adding JAR to build path under a folder

New to Eclipse, and I'm trying to figure out how to add a JAR to a build path UNDER a (what looks like) a library or class path? Here's what I have right now:
And this is what I want to have:
You see how in the second image, the JARs "core.jar" "ext.jar" and "frameworks.jar" appear under "2231 Libs"? I can't get that to happen, and I've tried everything I can think of. I would really appreciate help with this. Thank you.
Java->Build Path->User Libraries preference page. There, define a library and add all your jars to it. Then add the library to your class path in the build dialog box that you show in your screenshot.
Eclipse Java Help Contents: User Libraries

Where is the documentation for the GeoTIFF-jai Library

I am trying to use the GeoTIFF-jai Library to generate a geo-rectified, raster image in Java. I have tried looking on the SourceForge site for the documentation on how to do this, but SourceForge says "Unfortunately, this project hasn't indicated the best way to get help." Has anyone else tried using this library and been able to find any documentation on it?
If there truly is no documentation, maybe you can answer this question. When I import the library .jar file into my Eclipse project (using right-click->Import...->Archive File) all of the .properties files import but not the .class files. I need the GeoTIFFFactory class from org.geotiff.images.jai in order to create a new GeoTIFF image but it's not available. Any idea why the .class files are not importing? Am I doing something wrong on the import? Is the .jar in the wrong directory?
Any help with either of these questions is greatly appreciated.
Thanks,
Ryan
When I import the library .jar file into my Eclipse project (using
right-click->Import...->Archive File) all of the .properties files
import but not the .class files. Am I doing something wrong on the import?
Yes. That's not how you use third-party jars in Eclipse. The wizard you invoked is used primarily for importing archives with source code to make changes to them. Instead create Java project to hold your source code and add a dependency on the jar via Project Properties -> Java Build Path. You can also attach a source code archive in the same place (get this from project's site on SourceForge). This will let you see any available javadoc and if there is no documentation at all, you can at least step through the code.
Regarding lack of documentation, you will be more likely to get help on that project's forum rather than on stack-overflow (since the odds of you finding help on stack-overflow with a particular library is inversely proportional to that library's popularity).

Categories