I'm trying to make a simple program that calls the API to check video views after finding this example here but have run into a bit of trouble. I found the code needed to initialise a YouTube object here (https://github.com/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/GeolocationSearch.java#L90)
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
#Override
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("youtube-cmdline-geolocationsearch-sample").build();
I noticed that the code requires the class Auth, which is defined in the import
import com.google.api.services.samples.youtube.cmdline.Auth;
This is in an api-samples repo from Google and not included in the YouTube API dependency I have defined in my Maven pom.xml in my Eclipse project. I decided to just copy the Auth.java file and place it in my project's src/main/java folder but now I have another problem: 2 imports in Auth.java cannot be resolved. These are the ones:
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
You can see the entirety of Auth.java here.
In case it'll help here is the dependency definition from my pom.xml file:
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev20201202-1.31.0</version>
</dependency>
</dependencies>
Thank you for taking time to read this, and I hope you can find a solution for me. :)
Thanks to stvar's comment I looked at the pom.xml file from the api-samples repo and found what I was missing was a Google OAuth client thing. I added the following code to my pom.xml and the imports were resolved.
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.20.0</version>
</dependency>
Related
I've been trying to import spigot/bukkit for minecraft plugins. When trying to create the main class, I entered
public class Main extends JavaPlugin{
}
With an error under JavaPlugin, since their is no import. The tutorial im following told me to click the fix that will import it for me, but
the fix simply does not show up when I attempt to resolve it, and if I manually import it, it gives the error: "the import org.bukkit.plugin cannot be resolved." I've tried restarting the project, deleting and reinstalling, and everything in between. Please let me know if you need more information on how I've added spigot to the build path, or anything else I can help with.
Since the 1.17, it seems to have some changes with jar. Now, if you start server, it will create the bundler/versions folder, with a given jar that -for me- should fix your issue.
Also, you can use more preferable way to import project, such as maven or gradle. They can help you to easier share the project, and make it faster to run (you can also automatically run it with github actions for example.
To use spigot with maven, use this:
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
(Documentation)
To use spigot with gradle, use this:
repositories {
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
}
(Documentation)
I was reading the google document, i wanted to push my message into pubsub topic.
reference link:
https://cloud.google.com/pubsub/docs/quickstart-client-libraries#pubsub-client-libraries-java
Added the pom dependency as mentioned:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.82.0</version>
</dependency>
Example class used:
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/pubsub/cloud-client/src/main/java/com/example/pubsub/PublisherExample.java
But after doing everything not sure why the import of all the class is not working through maven.
Error i have in IDE:
Also, when i checked my Java build path all the google related jars are look like this:
Add more on it, multiple time updated/clean/build the project, Restart the eclipse 100 times.
Literally I am not getting what to do now, can anybody help what I am missing here.
Appreciated your help in advance.
I want to use sidecar to call flask with spring cloud, but when I import org.springframework.cloud.netflix.sidecar, hint does not exist.
I guess it's because there's no jar package for sidecar.But I don't know which jar package to use.
Who can help me?
thanks!
Need to include :
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-netflix-sidecar/2.1.0.RELEASE
I am still trying to get the example in this tutorial to work:
http://www.automationtestinghub.com/first-appium-test-script/
I am getting a ClassNotFoundException in the line:
AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(caps);
I have added java-client-6.0.0-BETA2.jar to my Build Path.
What am I missing?
This is not in any way connected to the question: How to resolve 'the import io cannot be resolved' - that part has been resolved.
Update 03/01/2018
I have converted my project to a Maven project.
Then I added the following to the pom.xml:
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.0.0-BETA2</version>
</dependency>
Then I ran Maven Build with Verify Clean.
The result was still the same:
ClassNotFoundException
Update 04/01/2018
Finally got this working.
I got a response from Appium support - “Selenium requires guava library to be in classpath.”
First I added the android version - but that gave a different error.
When I added the regular version - it all worked:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.6-jre</version>
<!-- or, for Android: -->
<version>23.6-android</version>
</dependency>
My advice would be to add maven framework support to your project.
If using IntelliJ do the following:
Right Click your folder structure and hit Add Framework Support
Then tick the Maven box and click OK to add this as a Maven Project.
You should then have a pom.xml generated within your folder structure open this.
Within this pom.xml you need to add the following code:
https://gist.github.com/michaelvoase/54f3bbf47b888bb004330a1d1b108068
This will then import the Appium library into your project.
I need to develop an application that would be able to download a given document from Google Drive. I have found out that the recommended technology to use in the Java world is currently the Google Drive SDK.
As described by the quick start guide I have imported the required dependencies to my Maven project like this:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev98-1.17.0-rc</version>
</dependency>
The official sample DriveCommandLine source code (to be found at the bottom of same page) refuses to compile with the following error messages:
The import com.google.api.client.json.jackson cannot be resolved (at DriveCommandLine.java, line 8),
JacksonFactory cannot be resolved to a type (at DriveCommandLine.java, line 27).
How do I fix it? I'm running Java version 1.7.
Apparently you need to import the following dependency as well in order for the code to work. It contains the JacksonFactory class.
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.16.0-rc</version>
</dependency>