I'm using the twitter4j 2.1.11 jar, but Eclipse doesn't seem to be able to find classes within it. I added the jar as a referenced library, but get Twitter cannot be resolved to a type when trying to use it. I can add imports like import twitter4j.* but not import twitter4j.Twitter.
I can tell the class is available as it is present when I open the jar in an archive viewer. How can I get Eclipse to behave?
The problem I was having was that I was importing the wrong archive, specifically the sources archive rather than the one found in /lib of the twitter4j download.
Related
I have following import in my class
import org.apache.commons.lang.exception.ExceptionUtils;
ExceptionUtils is indeed referenced in my class.
JOptionPane.showMessageDialog(this, "An Server Error occured during saving.\n\n" + ExceptionUtils.getStackTrace(e), "Error",**
But in the classpath i have package org.apache.commons.lang3
I am really not sure how this runs and why there are no errors?
I am using Eclipse Indigo
Please advice.
It sounds like your Apache Commons Lang .jar file satisfies your org.apache.commons.lang.exception.ExceptionUtils import.
Look here:
http://www.java2s.com/Code/Jar/a/Downloadapachecommonslangjar.htm
STRONG SUGGESTION:
Take a look inside of your .jar file. One easy way to do this is with a tool like 7-Zip, or jd-gui. Another way is to temporarily rename the file from .jar to .zip, and look at its contents in Windows Explorer.
This will show you the packages (directories and subdirectories) and classes inside of the .jar.
Interesting stuff - try it sometime!
I'm using play framework 2.1.1, and I want to add to a project restfb in order to use Facebook graph.
I added restfb-1.9.0.JAR to eclipse, then I right clicked on it, and chose build path->add to build path.
However when I'm trying to write some code, and use the restfb package, I'm getting an error code on the browser.
This is the error:
error: package com.restfb does not exist
On the line:
import com.restfb.FacebookClient;
Any idea on how I can fix this?
Thanks
Copy your libraries into the lib folder in your project folder. If the lib-folder does not exist, create it.
The Play Framework includes all jars in the lib-folder when building/compiling your app. Adding it to the eclipse-build-path is not enough.
I created a new Java app from scratch in IntelliJ IDEA. Now I want to use a jar library, e.g. OpenJPA. I added the library using Project Structure -> Libraries like this:
then I tried to use annotations from that library in my Java code, but I don't get the option to import these classes. It looks like IntelliJ IDEA is not known about my library yet:
What am I doing wrong when adding this library? Is there anything more that I have to do to get it working?
After adding this library, it looks like it is automatically added to "Modules":
You have created a library, but you haven't said IntelliJ that the module must use it. Click *ModulesĀµ in the project structure, then select the module you want to add this library to, go to the Dependencies tab, and add the library.
EDIT:
It's simply that the annotation is not part of the jar. You need to add the jpa api jar, not only openjpa.jar
You have to add library to Module dependencies, pls check here:
Configuring Module Dependencies and Libraries
I'm trying to make a small java program revolving around Google Calendars. I've never worked with java before but I was able to get Google's sample code working. In Eclipse, I simply used Import -> Maven, and then made some small changes to the code so that it worked on my Calendar.
Ok, great, now I want to write my own code. I started a new project and imported the Google Calendar API. At the very beginning, there are several import actions:
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
.
.
.
It turns out that I'm missing the second and third files. How do I find these files and how to do import them to the new project?
Please note: I ultimately don't want to rely on importing the Google Calendar API or anything similar, as I will be using another non-java program to run and control this one.
Here's what I tried:
I go back to the sample code, expand Maven Dependencies and find:
google-oauth-client-jetty-1.19.0.jar
google-oauth-client-java6-1.19.0.jar
I see that these files are in:
C:\******\.m2\repository\com\google\oauth-client\google-oauth-client-jetty\1.19.0
C:\******\.m2\repository\com\google\oauth-client\google-oauth-client-java6\1.19.0
I tried to add these with Import -> Java EE -> App Client JAR file
Didn't work, do I need to change the file name or import name? Maybe these aren't the correct files anyway.
I also tried to add these by creating a lib folder in my project folder and add the JAR files directly there.
I guess from your question your project is just an Eclipse project rather than a Maven project. Obviously Maven automatically add the required jars of the dependencies stated in pom.xml for example google-oauth-client-java6-1.19.0.jar is a dependency of google-oauth-client-jetty-1.19.0.jar.
To add external jar to your project in Eclipse you need to select the project then from the Project menu select Properties. On the properties popup click on the Java Build Path, you have two options depending where the jars are stored, if you are referring to the maven .m2 directory then choose 'Add External Jars' otherwise if you added them to a lib folder in the project choose Add Jars
A Domino XPages project I inherited is stating three errors:
The import com.ibm.xylem cannot be resolved
The import com.ibm.compat cannot be resolved
The import com.ibm.security cannot be resolved
I have ensured the correct XPages plugins have been installed. I have also removed the jars from the build path and re-inserted them and also cleaned the project but I still have these errors. I have also searched the internet for these jars but cannot find any.
What is going wrong with jars and project?
If you are trying to use non-standard libraries inside a Java agent, i think you have to import them in another way. When you open the agent in Domino Designer perspective, you'll see a drowdown button "Import". If you have, for example, the additional libraries as jar files, use Import > Archive.