unable to view akka http package in IntelliJ - java

I am trying to use akka http v10.0.2. I added akka-http in my build.gradle file (just akka-http, not http-core or any other akka http related dependency). I tried using the imports below but the 'akka.http.javadsl.server' does not seem available (even though I can see the package when I download the jar file and extract it). The other packages are visible. I have tried clearing the IntelliJ cache. Barring clearing my ivy cache, are there any other steps I can take to troubleshoot this further?
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.http.javadsl.server.AllDirectives;
import akka.http.javadsl.server.Route;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import java.util.concurrent.CompletionStage;

the issue was resolved by adding all the other akka http dependencies in my gradle build file. I will try to post the build file here when possible.

Related

Trouble importing Apache HttpComponents into BlueJ, package does not exist

I'm rewriting a project I made in Ruby into Java (14.0.1) as there is some functionality I would like to add, which I would be much better at in adding in Java. For this project, I'm trying to use Apache HttpComponents (Core & Client 5.0.1) https://hc.apache.org/downloads.cgi to handle GET and POST requests. I have taken the JARs from the downloaded libs and moved them to my userlibs, e.g. /BlueJ.app/Contents/Resources/Java/userLib/httpclient5-testing-5.0.1.jar then using the libraries menu in preferences I added all the jars from both lib folders so they are "(Loaded)".
When I try to import the libraries so I can use them, e.g.
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class Authorization
{
public Authorization()
{
}
}
I get the errors, "package org.apache.http does not exist", "package org.apache.http.client.entity does not exist", etc.
I have tried adding a lib folder in my project folder and importing from there, making sure to restart BlueJ for the changes to take effect, but to no avail. I have tried downloading eclipse and following a tutorial to import the JARs into the project (I forget the details bc I did it a couple days ago), but again to no avail. I know I am doing something wrong and I have spent numerous hours trying my best to troubleshoot but I'm stuck; I've never had to import libraries that weren't included in Java before and I'm gridlocked right now trying to work on a little summer project as I took my first computer science class over this past school year which I really enjoyed.
Thank you!

Google Analytics API 4 Java client running from command com.google.analyticsreporting.v4 package does not exist

I'm running the API 3 with Java from Windows command using javac and java to compile, no problem. I'm trying the API 4 but can't make even the basic example to run. I understand my problem must be in the classpath but can't pinpoint on the problem. Can't see the com.google packages
I downloaded the API 4 Java Client, copied all .jar in libs to a folder libs in my project. Also copied google-api-services-analyticsreporting-v4-rev110-1.22.0.jar to the libs
I'm testing the service account example as in
https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-java
I setup the compiler as (I know the path exists)
javac -classpath ".;C:\Java\GAnalytics\libs\*" HelloAnalytics4.java
I also tried adding the subdirectories in the client
Error Package does not exit:
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.analyticsreporting.v4.AnalyticsreportingScopes;
import com.google.analyticsreporting.v4.Analyticsreporting;
import com.google.analyticsreporting.v4.model.ColumnHeader;
import com.google.analyticsreporting.v4.model.DateRange;
import com.google.analyticsreporting.v4.model.DateRangeValues;
import com.google.analyticsreporting.v4.model.Dimension;
import com.google.analyticsreporting.v4.model.GetReportsRequest;
import com.google.analyticsreporting.v4.model.GetReportsResponse;
import com.google.analyticsreporting.v4.model.Metric;
import com.google.analyticsreporting.v4.model.MetricHeaderEntry;
import com.google.analyticsreporting.v4.model.Report;
import com.google.analyticsreporting.v4.model.ReportRequest;
import com.google.analyticsreporting.v4.model.ReportRow;
What am I missing?
Same problem for me, I solved by substituting all
"com.google.analyticsreporting.v4" ---> "com.google.api.services.analyticsreporting.v4"
and also:
Analyticsreporting --> AnalyticsReporting
Here the screen of the google-api-services-analyticsreporting-v4-rev111-1.22.0.jar unzipped

find neo4j libraries for java api

I want to use neo4j libraries to connect my java app with neo4j database and follow the tutorials from http://neo4j.com/docs/stable/tutorials-java-embedded-hello-world.html.
At the beginning I copied the sources code from https://github.com/neo4j/neo4j/blob/2.2.2/community/embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4j.java and netbeans complains about missing libraries like:
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.io.fs.FileUtils;
I have searched libraries from http://search.maven.org/#search|ga|2|g%3A%22org.neo4j%22 site for example:
org.neo4j.graphdb
But can not find anywhere. Where can I find libraries?
You need the neo4j-kernel artifact and all of its (transitive) dependencies, see http://mvnrepository.com/artifact/org.neo4j/neo4j-kernel.
Have you looked at http://search.Maven.org and searched Neo4j?

How to add (import) java websocket library to my project?

First, sorry if question is trivial - I'm new to java world.
So, I've created new project. Then I downloaded websocket jar file here:
http://www.java2s.com/Code/Jar/j/Downloadjavawebsocket130jar.htm
After that I've created 'lib' dir, copyed jar file there, selected it, added to build path.
Basically, I was following instructions from here:
http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29
Then I copied source code into my class:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
So, first part of imports is ok...standard Java imports. But problem is second group. For every import, starting from:
import org.java_websocket.WebSocket;
I'm getting error "Import.... can not be resolved." And rest of the code that's using those classes is shooting errors because of that of course.
So, I added jar file to build path, but I still can't import classes from that library. What's missing here?
First, extract the jar from the zip file, then right click the folder you're working on in your Eclipse. Click "Build path", then click "Configure Build Path", then click on "Libraries" and on the right hand side click on "Add external Jars", and then find your extracted jar.
Download the bundle from the below repository.
MVN Repository
This should resolve your issues.

Which version of Netty API does this example code use? Unable to resolve io.netty.handler.codec.http.DiskFileUpload with 3.2.x

I came across this sample code for handling file uploads with Netty, this looks perfect, just what I needed. Unfortunately I am having difficulty incorporating this class as many Netty API features are unresolved. One of them for example is io.netty.handler.codec.http.DiskFileUpload, I am unable to find this in any of the online API docs for 3.0,3.1.3.2.
The class I am having issues with is here:
https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java
I have tried using netty-3.2.5.final, 3.3.1.final, 3.4.0.Alpha
Unresolved imports:
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.EndOfDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.ErrorDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.IncompatibleDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.NotEnoughDataDecoderException;
import org.jboss.netty.handler.codec.http.InterfaceHttpData;
import org.jboss.netty.handler.codec.http.InterfaceHttpData.HttpDataType
import org.jboss.netty.handler.codec.http.HttpDataFactory;
import org.jboss.netty.handler.codec.http.DiskAttribute;
import org.jboss.netty.handler.codec.http.DiskFileUpload;
import org.jboss.netty.handler.codec.http.FileUpload;
import org.jboss.netty.handler.codec.http.DefaultHttpDataFactory;
import org.jboss.netty.handler.codec.http.Attribute
Any help appricated
When you see the org.jboss.netty namespace, that indicates v3.x
io.netty is used in v4.
Online documentation is located at http://netty.io/docs/
It's under master branch which is 4.0.0.Alpha1-SNAPSHOT from the pom.

Categories

Resources