I have tried to use the org.json.XML class in my Android project. This class isn't provided by the core library's so I thought the only thing I had to do is use the updated org.json package with gradle. But I'm getting the following error when I'm trying to compile:
error: cannot find symbol class XML
Here my MainActivity import:
...
import org.json.XML;
...
And my build.gradle file:
dependencies {
...
compile 'org.json:json:20160212'
...
}
I know that Android Studio is compiling the jar and that is working, but I want to know a way to get it working using the maven dependencies.
I recommend you to use Jackson library to parse XML files.
Or if you want to keep doing it by yourself you can try using javax.XML
http://developer.android.com/reference/javax/xml/package-summary.html
instead of org.json.xml
Hope it helps!
This is maven dependency for org.json.XML
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
Source: http://mvnrepository.com/artifact/org.json/json/20160212
Related
In a project using Maven & JavaFX, I'm trying to add this dependency in my pom.xml
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
I did that - I reloaded my maven changes (using intellij), but I still can't use this package.
When I wrote this in my code:
import org.json.JSONObject;
I've gotten this error
Package 'org.json' is declared in module 'json', but module 'com.example.demo' does not read it
And I don't understand why. I thought I might need to add it in module-info.java, but after some googling I think that I don't, because in that file I have to specify the dependencies for the JavaFX.
So... what does that error mean?
Thanks.
Add this line to your module-info.java:
requires json;
To understand what it means, see:
Understanding Java 9 Modules.
I just generated code using Swagger.io with the OpenApi 3.0 spec. The code it produces doesn't compile. Once class has this seemingly crucial import:
import springfox.documentation.oas.annotations.EnableOpenApi;
But I get this error: package springfox.documentation.oas.annotations does not exist
I can't figure out what I need to add to my pom.xml file to make the import work. The maven repo at https://mvnrepository.com/ doesn't let me search for a specific class, which makes no sense.
I hope you have missed swagger oas dependency so you are getting package not exist error. Swagger oas available in the below maven repository.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-oas</artifactId>
<version>3.0.0</version>
</dependency>
I have been doing my project and all the sudden eclipse started to give this error saying
The type com.google.protobuf.GeneratedMessageV3$Builder cannot be resolved.
It is indirectly referenced from required .class files where we declare the package. I have tried adding com.google.protobuf-2.4.0.jar to build path but it did not work. Please help and here's the screenshot.
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute is not on the classpath so remove this import
If you are expecting Protobuf generated files to be available, then ensure that you have added the Protobuf library to your project.
Gradle example:
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: googleProtobufVersion
Maven example:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${googleProtobufVersion}</version>
</dependency>
Not sure if this helps at such a later date. But i also faced something similar.
I found that I imported this by mistake
import com.mysql.cj.x.protobuf.MysqlxDatatypes.Array;
After removing this line, it works fine.
In your case you need to remove the import
com.mysql.cj.x.protobuf.MysqlxSql.StmtExecute
Replace it with the relevant import.
This is due to the missing dependency of gRPC protobuf. Add this dependency to your pom.xml and this should solve your problem.
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.16.1</version>
</dependency>
Lastly, do maven -> project update
I'm following this, but I'm having problems with creating the engine object (as described by the Java section of the code). I have 3 import lines that cant be resolved and I cant find where to get the files. i am still a novice coder so this is appreciated.
See here for the java library and how you can import it
Direct download link for a .zip file
For maven add to pom.xml:
<project>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-mapsengine</artifactId>
<version>v1-rev64-1.20.0</version>
</dependency>
</dependencies>
</project>
for gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.apis:google-api-services-mapsengine:v1-rev64-1.20.0'
}
By the way, Google Maps Engine API will stop working after jan 29th, 2016, so don't waste too much time getting used to it ;-)
I am trying the Java code example in the Getting Started (Authoring AWS Lambda Code in Java) page, but am stuck as com.amazonaws.services.lambda.runtime pacakge seems to be missing
Here is the sample code:
package example;
import com.amazonaws.services.lambda.runtime.Context; //package does not exist error
import com.amazonaws.services.lambda.runtime.LambdaLogger; // package does not exist error
import com.amazonaws.services.s3.AmazonS3; // import works (not needed, I've put them in for testing import)
import com.amazonaws.services.s3.model.S3Object; // import works (not needed, I've put them in for testing import)
public class Hello {
public String myHandler(int myCount, Context context) {
LambdaLogger logger = context.getLogger();
logger.log("received : " + myCount);
return String.valueOf(myCount);
}
}
I encounter the same error both in Netbeans and through command line (specifying the aws sdk thorugh -cp argument) from the first two imports of the code:
package com.amazonaws.services.lambda.runtime does not exist
Note importing other packages from the SDK works fine, as per third and fourth imports from the above code (the s3 imports which i put in just to test).
I am using version 1.10.2 (aws-java-sdk-1.10.2.zip) of the AWS Java SDK, downloaded from http://sdk-for-java.amazonwebservices.com/latest/aws-java-sdk.zip
Any directions/suggestions would be much appreciated. Thanks!
Both of those classes are contained in the aws-lambda-java-core jar, which is distributed separately from the AWS SDK. You can download it from maven central at the link above if you're not using maven/gradle/some other build system that can natively pull from maven central.
Add AWS plugins within eclipse from market place, make aws lambda project.
Use below three dependencies to make fat jar.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-lambda</artifactId>
<version>1.11.76</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.3.0</version>
</dependency>
After some searching I found com.amazonaws.services.lambda.runtime.Context in http://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-core/1.1.0 . (I prefer this site to search.maven.org. mvnrepository.com gets right to the heart of my problem by supplying the sbt build line.)
The class is not in aws-java-sdk-lambda , nor is it in aws-java-sdk-core, or aws-java-sdk .
For those who are using sbt:
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.11.241",
"com.amazonaws" % "aws-lambda-java-core" % "1.2.0"
)
Check the links for the lastest version:
https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-core
Arthur,
You trying use java code sample from AWS Lambda for another product Amazon AWS SDK For Java.
Please read AWS Lambda welcome-page and maybe after steps for (create account and others) you can to download package with your classes (Context, LambdaLogger)
For me, the solution for intellij was delete all .iml files and invalidate cache/restart.
I found com.amazonaws.services.lambda.runtime.LambdaLogger in: https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-log4j/1.0.0
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j</artifactId>
<version>1.0.0</version>
</dependency>