Cannot resolve method 'read' in 'JsonPath' - java

I currently have a gradle project where I have a line implementation "com.jayway.jsonpath:json-path:2.4.0" in my build.gradle file. In my code, I have an import statement import org.springframework.data.web.JsonPath;, but when I actually use the JsonPath e.g. obj.put("key", JsonPath.read(jsonStr, "key1.key2.key3.key4"));, the read method appears as red in my IDE saying that it "Cannot resolve method 'read' in 'JsonPath'". I have tried refreshing gradle dependencies and closing/opening the IDE/window but nothing works - any thoughts?

remove this
import org.springframework.data.web.JsonPath;
use this
import com.jayway.jsonpath.JsonPath;
Read this documentation to know more about available methods.
Hope this helps.

Related

VS Code - The import "#####" cannot be resolved

So, i am running a java project which have many library that are available in the current working directory but VS code seems to not recognize these library and giving out error "The import ###### cannot be resolved" ex: The import org.apache.pdfbox.pdmodel.PDDocument cannot be resolved"
here is the image that might help you to know more about it
This is the package that i am working on :
Here the org/apache is the library contain the class file that are need to be imported and FileArrangement.java is the file having the import statements
Error i have been receiving
this is what VS code is been showing
i really need your help because i really don't have any idea how to correct this
I have checked other projects and they are also showing the same result although the import statements for java classes like . java.util.ArrayList doesn't show any kind of error and i have tried to clean java in VS code it also didn't work
i just need to correct this error of VS code to import the classes that i need
No error on java.util package
Putting the libraries in your current working directory does not work for Java, you need to add them to the classpath.
If you're using maven, that manages the classpath for you.
If not, you can manage it in VS Code by executing the Java: Configure Classpath command from the Command Palette (Ctrl+Shift+P).
You can add dependencies via Referenced libraries under the JAVA PROJECTS panel.
Or use java.project.referencedLibraries setting in settings.json.
For example:
"java.project.referencedLibraries": [
"library/**/*.jar",
"/home/username/lib/foo.jar"
]
Details can be found in configure-classpath and manage-dependencies.

Kotlin Extensions - Inflate Custom Views

I'm new to kotlin, I Have an adapter class and I need to inflate a view. but recently I'm facing an error saying "Unresolved reference: R"
Like in the image below :
So, how can I inflate this view? I have imported the following:
import kotlinx.android.synthetic.main.slide_layout.view.*
But I can't figure out what should i do next, I searched everywhere, but they all seem outdated! so what should i do? Thank you!
There are two possible issues i can think of,
The first is a missing import to the R class, if your adapter is in an inner package from your domain package name, i.e.
assume this is the domain package 'your.doamin.package'
if adapter is not in that package i.e. adapter is in 'your.domain.package.adapter'
then you need to import the R class into that file, i.e write this import statement
import your.domain.package.R
That should fix your problem for this scenario
If you have already done '1' above then the other issue is, Sometimes Android studio just misbehaves, so close the file and clean and build your project by first clicking, Build -> Clean Project, once the build is done reopen that file.
For resolving the error unresolved reference: R, you are missing import of your R file. Something like
import packageName.R
For your reference, I am attaching a screenshot of the error and see the commented import.
So check where your R.java resides and import that.
First you check your class import statement in that your R class file imported or not.
import packageName.R
also you can set android studio provide auto import features. if you can enable this feature then all required class automatically import your .kt class
Unfortunately not all answers here can solve your problem, I've been looking for general solutions, you can find them
Here

How to import file from other folder in java?

I have just started learning java, so struggling in very basics. The problem i am facing currently is "cannot find symbol : class Ques". I have resolved this issue when i was accessing package from parent directory through CLASSPATH export. Now problem is i am trying to access sub-directory from sub-driectroy like this:
family.of.adam(has)/
father.java
WifeOne(sub-direc)/wifeone.java,ChildFromWifeOne.java
WifeTwo(sub-direc)/wifetwo.java,ChildFromWifeTwo.java
Now what i am trying to do is from wifetwo.java i am accessing wifeone.java. I have tried importing (wifeone)like this:
import family.of.adam.WifeOne.*;
import WifeOne.*;
In both cases it failed to import and same error occured which i mentioned above.
I have also tried solution provided in this Question but this effects classpath of WifeOne this is what i think because when i -cp method it starts showing errors related to wifeone.
I am using normal texteditor, compiling through terminal and using mac. Kindly brief me what mistake i am doing.
Assume src is your base folder(place you compile and run the program).
src/family/of/adam/FirstWife.java
if so you need to define the package startmetn the fist line of the FirstWife.java file.
package family.of.adam;
Then,If the second java file in the,
src/Main.java
In Main.java file you need to define the import statement for user the FirstWife.java class.
import family.of.adam.FirstWife;

what does it mean when there is import error?

I am using a code sample that suppose to be working, but I keep get an error with those 3 import statement.
import com.amazonaws.services.s3.transfer.internal.MultipartUploadCallable;
import com.amazonaws.services.s3.transfer.internal.PutObjectCallable;
import com.amazonaws.services.s3.transfer.internal.TransferStateUpdatingCallable;
the error message says : The import com.amazonaws.services.s3.transfer.internal.MultipartUploadCallable cannot be resolved
why is that happening and how can I solve it ?
Please add jars that contain this classes. This will always solve your problem.
This means that implementations of referenced classes cannot be found in classpath. Since you are using amazonaws you should add appropriate library to your project's dependencies.

Com.Google.Common.*.*... import failure

I'm working on a project and need to use the Predicate interface of google's common.base
I tried importing the google-collect jar at http://code.google.com/p/gdata-java-client/source/browse/#svn/trunk/java/deps
I got the jar, imported it in my library but nothing's there...
Can anyone tell help me to be able to work with this interface?
If you are using eclipse, you need to add the library jar to your build path, as described here.
If you are compiling from the command line, use the -classpath option to add the jar to the path.
Also make sure the case is correct in your import declaration. The import should look like
import com.google.common.base.Predicate;
not
import Com.Google.Common.Base.Predicate;
Also you probably know this already, but the import com.google.common.*.* suggested by your question title is invalid - you can only have one *. (import com.google.common.base.* is OK.)

Categories

Resources