Cannot resolve files when importing them Google API's - java

I'm developing a Glassware for Google Glass. I'm trying to import these files:
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.oauth2.Oauth2;
import com.google.api.services.oauth2.model.Userinfo;
but I'm getting errors on them. They are below:
The import com.google.api.client.json.jackson cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved
I'm not sure why I'm getting these errors. I'm building off of the quickstart java project. My Maven Dependencies are below:
C:\Users\Family3\.m2\repository\com\google\apis\google-api-services-mirror\v1-rev20-1.16.0-rc\google-api-services-mirror-v1-rev20-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\api-client\google-api-client\1.16.0-rc\google-api-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\oauth-client\google-oauth-client\1.16.0-rc\google-oauth-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client-jackson2\1.16.0-rc\google-http-client-jackson2-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client\1.16.0-rc\google-http-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpclient\4.0.1\httpclient-4.0.1.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpcore\4.0.1\httpcore-4.0.1.jar
C:\Users\Family3\.m2\repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar
C:\Users\Family3\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.1.3\jackson-core-2.1.3.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty\6.1.14\jetty-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\servlet-api-2.5\6.1.14\servlet-api-2.5-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-util\6.1.14\jetty-util-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-plus\6.1.14\jetty-plus-6.1.14.jar
C:\Users\Family3\.m2\repository\geronimo-spec\geronimo-spec-jta\1.0.1B-rc4\geronimo-spec-jta-1.0.1B-rc4.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-2.1\6.1.14\jsp-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\eclipse\jdt\core\3.1.1\core-3.1.1.jar
C:\Users\Family3\.m2\repository\ant\ant\1.6.5\ant-1.6.5.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-api-2.1\6.1.14\jsp-api-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.9.11\jackson-core-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.11\jackson-mapper-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
C:\Users\Family3\.m2\repository\commons-logging\commons-logging\1.1.2\commons-logging-1.1.2.jar
C:\Users\Family3\.m2\repository\commons-codec\commons-codec\1.7\commons-codec-1.7.jar
C:\Users\Family3\.m2\repository\com\google\guava\guava\14.0.1\guava-14.0.1.jar
Why am I getting these errors? Am I not importing a .jar? I can't find any .jar's that aren't included that should be, but there could be one. Thank you for your help.

Add the client libraries to the project.
See download and setup instructions for google-api-java-client.

try adding:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>{version}</version>
</dependency>

Related

The import org.hibernate.validator.ClassValidator cannot be resolved and The import org.hibernate.validator.InvalidValue cannot be resolved

After migrating to the hibernate-annotations:3.5.6-Final jar, I'm trying to use the ClassValidator class.
But the import org.hibernate.validator.ClassValidator<User.class> is not getting resolved.
I also have the compatible dependencies org.hibernate.hibernate-annotations:3.5.6-Final and org.hibernate.hibernate-validator:5.1.3.Final
before migrating to the hibernate-annotations:3.5.6-Final jar, there were no issues with the ClassValidator<User.class>
Earlier I had the dependencies org.hibernate.hibernate-annotations:3.2.0.GA and
org.hibernate.hibernate-validator:5.1.3.Final, it was working well
I am not understanding the issue. How do I resolve the errors with hibernate-annotations:3.5.6-Final and hibernate-validator:5.1.3.Final, which are the suggested dependency jar in my demo project?
Please help me with this

Java 8 to openJdk 11 com.sun.org.apache.xml.internal.* types not accessible

I am migrating my project from java 8 to openJDK 11. In my code I use the classes
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMManager;
import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
import com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl
I am using eclipse. I am getting the error that the types are not accessible. I also tried this post with the last import How to tell eclipse to add-exports when compiling
But it did not work. Any idea how could we fix this? Does the error mean that the packages have become internal and should be replaced in the code?
I had a similar issue where I needed to update a reference to com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory, and found I could change it to:
import org.apache.xml.serializer.OutputPropertiesFactory;
if I included the right Xalan apache xml dependency:
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
</dependency>
In openJdk11 you have to import xml-security.jar ( com.sun.org.apache.xml is not present so you have to)

Understanding JIRA dependencies and package imports

I'm relatively new to JIRA plugin development and as I'm working through various tutorials I've run into a problem where I can only import certain JIRA java classes. For instance, when trying to compile this tutorial to create a custom search request view https://developer.atlassian.com/jiradev/jira-platform/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/search-request-view-plugin-module I found that I can successfully import the following packages:
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchRequest;
but cannot import these packages:
import com.atlassian.jira.issue.search.SearchProvider;
import com.atlassian.jira.issue.search.SearchProviderFactory;
Both SearchProvider and SearchProviderFactory are present in the javadocs for the latest version of JIRA, yet I can't import them despite them being in a package from which I've already imported.
Why is this? I suppose it's some sort of dependency issue but I can't seem to find a way to fix it. I'm developing in Eclipse, by the way.
Any help is appreciated. Thanks!
The problem was that in the generated pom.xml for JIRA plugin projects, the jira-core dependency is commented out. To access all developer classes, the following must be enabled.
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

java: package does not exist error only after build

I'm trying to add the JCodec library to my android studio project. I followed the steps listed here. I import these four lines:
import org.jcodec.codecs.h264.H264Decoder;
import org.jcodec.common.AndroidUtil;
import org.jcodec.common.model.ColorSpace;
import org.jcodec.common.model.Picture;
I get no errors until I build my project. When I build the project, I get an error that each of the packages I tried to import don't exist. Does anyone know what the problem is?
Thanks!
I did not really understand how linked answer helped you to add library because it is for Eclipse and you are using Android Studio and Gradle.
In build.gradle you should add:
dependencies {
...
compile 'org.jcodec:jcodec:0.1.9'
...
}
I figured out my problem. The issue was that I added the library under libraries but it wasn't a jar file, it was an android project. What I did to solve the problem was adding it as a module and then adding the module as a dependency to my project.

Import custom lib Java

Trying to import the "custom" library "Htmlunit" in my project. I use the IDE Netbeans and have done the following:
Right click "Library"
Clicked "Add Library"
Created the Library and added it
I then want to import the jar "htmlunit-2.15" but Netbeans tell me the following:
'.' expected
I have tried the following formatting:
import htmluni-2.15;
import htmlunit-2.15.*;
import Htmlunit;
import Htmlunit.*;
I have read other threads here, but do not understand to the fullest how I accomplish this.
Image: [http://s8.postimg.org/7ru7csh5h/import.png][1]
It doesn't work that way, you import in your code actual classes, not jars. I suggest you reading more about classpath, since it's a basic topic.
Probably you need to open the jar archive and see it's internal directory structure. When a class you are interested in a class is located, say, under file.jar -> com/example/Utils.class, you need to import it using:
import com.example.Utils
Create new project Maven->Java Appliacation. Find file pom.xml, and add this
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
Maven automatically download the library and add them to project.

Categories

Resources