I have installed eclipse ide for EE developers and I am receiving an import error for
import javax.json.Json;
import javax.json.JsonReader;
etc.
I have right clicked on project folder -> clicked properties -> clicked Java build path -> add library -> JRE System Library,
but the dependencies that show up are already imported. How can I import the javax.json package?
If using Maven, add this dependency to your pom.xml
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
For Gradle, add this to your build.gradle
compile 'javax.json:javax.json-api:1.0'
Going to assume that you are not using Java 7 and thus need to add the JAR file directly to your project path:
Here's the link to the
JAR
And where it came from:
http://jsonp.java.net/
Download and add to your project build path.
You need to get a hold of the Jar from https://java.net/projects/jsonp/
Then got to project folder -> clicked properties -> clicked Java build path -> Add External Jars...
From here you can import the downloaded Jar (library) into your project.
Using javax.json group (what is in the accepted version) doesn't work for me. I get this:
javax.json.JsonException: Provider org.glassfish.json.JsonProviderImpl not found
Instead, what does work for me is the following (put this in the dependencies section of build.gradle if you're using Gradle):
implementation "org.glassfish:javax.json:1.1.4"
To find the latest version of the library, see the library's search.maven.org page.
You will have to download the Jar from https://java.net/projects/jsonp/ as they are not yet part of main Java runtime, download the jar and add it to your classpath and it should work
JSR http://jcp.org/en/jsr/detail?id=353
Related
I have a project that requires me to import a library, and I am doing it in eclipse. I have imported the library, and it doesn't seem to recognize that I have the library imported.
My user libraries.
The build path for the project.
A picture of my java project. The part highlighted corresponds to the import statement.
How can I make it so that eclipse can see that I have the library imported?
I tried changing java versions and also changing the build path as well.
Adding the below Dependency in pom.xml for importing the libraries.
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0-0</version>
</dependency>
I'm trying to make use of a jReddit library, which, in turn requires apache HttpComponents and Commons IO libraries.
I downloaded the sources, added them in Itellij Idea through File - Project Structure - Modules - Add Content Root.
All the classes from the libraries that my code makes use of are imported successfully. But the problem appears when compiling - it says that package com.github.jreddit.oauth does not exist and package org.apache.http.impl.client does not exist and that it cannot find symbol of those libraries' classes.
Why does this happen and how to fix it?
Don't use Maven or Gradle if you can't even manage adding a JAR to your project manually.
You should acquire those JARs (containing .class byte code files, not .java source), add them a folder in your project named /lib, and add that directory as a JAR source location in your project. They'll be in the CLASSPATH then.
You need to add the /lib folder to an artifact when you run. Be sure you know how to do that as well.
I ran into this error after upgrading IntelliJ to version 2019.1. These steps fixed it for me:
Click Run from the toolbar
Choose Edit Configurations
Make sure the Scratch file you want to run is selected on the left panel
In Use classpath of module dropdown, select the project module that contains the proper module
I've got to get the HtmlUnit dependencies working by tomorrow to complete a project. I need to use java to access a webpage, fill in a form and click some buttons - HtmlUnit has been recommended for this.
I have downloaded the htmlunit 2.19 bin files which appears to have the jar dependencies and a bunch of documentation on how to use certain features - but there is no 'installation' steps.
Can someone please step me through the installation of the jar dependencies?
I am using Windows 7 and NetBeans IDE 8.0.2.
Thank in advance :)
I fixed the problem. In the libraries menu, I was just adding the folder that contained the jar files. I had to remove that and then add all the jars individually. – Joe
ref: Java: how to setup htmlunit
Right-click my project -> Properties -> Libraries -> Add JAR/Folder
Then add each jar individually.
In the downloaded htmlunit-x.y-bin.zip file, there is a lib folder, which contains all the dependencies.
or you can use maven:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
I have downloaded and am trying to import this library: https://github.com/sachin-handiekar/jInstagram in one of my projects. However, whenever I point to the directory where this project is located and try to import it, Eclipse says "No projects are found to import." I even tried importing it as Android code but it didn't recognize it either. How do I import and use this library in my Android project?
Just to use this library within your project add it as a Maven dependency
<dependency>
<groupId>com.sachinhandiekar</groupId>
<artifactId>jInstagram</artifactId>
<version>1.0.9</version>
</dependency>
If you don't know how to do this check this plugin: maven-android-plugin
You can also checkout the complete source tree for the project and then go to the directory containing the pom.xml file and using Maven run mvn install to build this project and then import it to the Eclipse.
It says no projects are found to import because it is looking for the eclipse .project file which is not included in git repositories. Try the import file system option
Or better yet, try out the git plugin for eclipse
Its easy, in Activity press Ctrl + Shift + O
I am now going to use the .jar file on http://code.google.com/p/google-api-translate-java/. However, after I download it, I tried to import it in my current project folder (in Eclipse)
the two import statements
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
always get complained by the compiler saying couln't find such class
Could any one help on how to correctly import this .jar file into a project in Eclipse?
You need to add it to your build path. Right-click on the project in Project View, select Build Path->Configure Build Path, then Libraries tab. Now, use one of available options there to add a JAR.
Use "Add JAR" if you copied the jar to your project folder or "Add External JARs" to add it by poiting to a path in filesystem. (Anyway, it is better to copy the jar to the project folder, in which you want to use the jar).
HTH
see How to import class into existing Java project, with Eclipse
Copy the google-api-translate-java-0.92.jar file to your project /WEB-INF/lib/ folder and refresh your project (right click on project and select "refresh").
Google Translate API v1 is deprectaed and will shutdown soon.
You can use Google Translate API v2 Java. It has a core module that you can call from your Java code and also a command line interface module.
Hy I have faced the same issue and fixed it
Step1: download google-translate-api jar file
step2: paste into your app library file
step3: Goto project structure > app > select dependencies -> then add path of your jar file...
Enjoy now you can acess google api services