Trouble importing Apache HttpComponents into BlueJ, package does not exist - java

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!

Related

unable to view akka http package in IntelliJ

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.

java.util.logging does not exist bug?

I am trying to import java.util.logging into my class but it doesn't exist.
I am using Netbeans 8.2 installed just a few weeks ago, when I started learning Java and Netbeans.
I found this old bug report Bugzilla report but this is so old, I would expect it to be fixed, especially for a logging function.
The following is the only code I have in the class file. The 2 java.awt classes import OK. I added those just to prove that I had access to the standard Java library. The auto suggest does not suggest anything starting with log...
package myflag.flag.logging;
import java.util.logging;
import java.awt.Color;
import java.awt.Font;
Any ideas please???
Only a type can be imported. java.util.logging is a package. Please specify directly what class you need to import or you can import like this for all class inside this package: import java.util.logging.*;

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

Media won't instantiate despite correct import packages in java

my Media object does not want to instantiate and i have all the correct imported jar files including JavaFX so that I can play mp3 files.
I have the imported packages:
import javax.media.*
import com.sun.media.MediaPlayer;
import com.sun.media.codec.audio.mp3.*
import javax.print.attribute.standard.Media;
But it still doesn't run. Any suggestions would be appreciated as i've been googling everyting about media and plugins for days now :(
You must import this packages:
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
Here is example of mp3 player.
You have to delete com.sun.media.mediaPlayer;
I had the same problem just now xD. Hope this helps.

How to add 3rd party JAR's to compile time classpath in jGRASP?

What do I need to do to successfully the import ij package? I get an error:
ITCN_.java:1: package ij does not exist
The imports are:
import ij.*;
import ij.io.*;
import ij.gui.*;
import ij.process.*;
import ij.measure.*;
import ij.plugin.*;
import ij.plugin.frame.*;
import ij.plugin.filter.PlugInFilter;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
import java.text.*;
I also used Jgrasp back in the day.
I highly recommend moving to eclipse although jGrasp is very simple and works.
To Add to the Build Path you go to Settings -> PATH/CLASSPATH -> Workspace
Click on the "Path" tab, and then the "CLASSPATHS" subtab.
Then Click "New" and where it says Path or Jar file, enter in the path to the ij jar file. Do this for each file if there are more than one.
And then click "apply" and you should be able to use import ij.* and the subsequent functions
It's the ImageJ API. The API docs are available here. You can download it here. Once downloaded, just add the JAR(s) to the compiletime and runtime classpath.

Categories

Resources