I am getting this error:
Java : The constructor JSONTokener(InputStreamReader) is undefined
I found the latest version of json and add that library but the problem didn't resolved, which I guess is because it is using another library.
Based on this post I need to find which library contains JSONTokener.How can I do that? None of the libraries' names contains json! I am using eclipse.
This is the import line of my program for this class:
import org.json.*;
To the OP: note also that as well as configuring the list of libraries, jars, folders, etc. in the build path, you may have to manually-adjust their order (using the 'Order and Export' tab).
Related
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.
In my Eclipse Plugin I have a table that shows Integer and String values. To edit the String values I'm using a TextCellEditor which is in the package org.eclipse.jface.viewers.
I have found a NumberCellEditor which I want to try. It is in the package org.eclipse.ve.internal.propertysheet.NumberCellEditor.
I cannot see this package in eclipse it is not listed in the plugin.xml file under Dependencies. It's not in the list that shows up when clicking the "Add"-Button either.
How can I use this class?
org.eclipse.ve appears to be the old Eclipse Visual Editor plugin which is no longer available.
Additionally classes in a package with internal in the name are off-limits (see Eclipse API Rules of Engagement). They may be changed or removed at any time.
I'm generating PDF report using JasperReports library. I this report I have a QRCode which makes problem. I had to add many libraries:
jasperreports, itext, itext-pdfa, itext-pdf, commons-beanutils, commons-collections, commons-digester, commons-logging, groovy-all, barbecue, barcode, barcode4j, batik-anim, batik-bridge, core, w3c.css.sac, w3c,xmlgraphics-commons, batik-all
I receive an exception:
java.lang.ClassCastException: org.apache.batik.anim.dom.SVGOMDocument cannot be cast to org.apache.batik.dom.svg.SVGOMDocument
at org.apache.batik.bridge.BridgeContext.setDocument(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.ensureSvg(AbstractSvgDataToGraphics2DRenderer.java:166)
at net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.getDimension(AbstractSvgDataToGraphics2DRenderer.java:111)
at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.processGraphics2D(JRPdfExporter.java:1793)
at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.process(JRPdfExporter.java:1582)
at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.access$300(JRPdfExporter.java:1535)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1475)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1093)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:1056)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:920)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:537)
at reports.JasperReport.generatePdf(JasperReport.java:178)
What is wrong?
If this is your own code (you wrote it), it is just because of you have imported the wrong SVGOMDocument class (which belongs to different Java package).
You should be able to figured it out quickly with decent Java IDE (Eclipse, IntelliJ, NetBeans).
Also, as much as possible try to avoid implicit imports such as:
import org.apache.batik.dom.svg.*;
import org.apache.batik.anim.dom.*;
That might reduce your code stability, e.g. lines added above might alter your reference of existing working code.
Use explicit imports (import org.apache.batik.dom.svg.SVGOMDocument).
Find out what's the return type of the method you invoke, and import from the correct Java package. In Eclipse IDE, you can just remove the import that contains the package/class above, and choose Source > Organize Imports (Ctrl-Shift-O).
If you have both classes in single source code file, you might need to use full class name for one of the classes, e.g.:
org.apache.batik.dom.svg.SVGOMDocument document = SomeLibrary.getSomething();
I added the common lang jar file in the classpath, but when I compile it says:
error: package org.apache.commons.lang does not exist
I tried to follow the steps described below:
http://oopbook.com/java-classpath-2/classpath-in-jcreator/
but I don't it doesn't work. Is it the editor that's not working properly or is it something else?
Between major versions 2 and 3 apache changed the package naming scheme on their classes from lang to lang3.
Notice on the download site that for version 2.6 you are downloading "commons-lang-2.6" and for version 3.3.2 you are downloading "commons-lang3-3.3.2".
Also, if you check out the current API doc you'll see the new naming structure.
All you need to do is update your import statement to match the new package structure and your compiler will be able resolve it correctly.
I'm writing a Java class that will be used to send PDUs across a network- to do this, I am following the tutorial at: Tutorial
In the example, the line:
double lla[] = CoordinateConversions.xyzToLatLonDegrees(c);
appears towards the end of the class, and I see that CoordinateConversions has been imported with the line:
import edu.nps.moves.disutil.CoordinateConversions;
I have tried using the xyzToLatLonDegrees(); method in the class that I am writing- calling it in the same way as is done in the example. However, for some reason, I get a compile error that says:
CoordinateConversions cannot be resolved
on the line where I'm trying to use it, and
The import edu.nps.moves.disutil.CoordinateConversions cannot be resolved
on the line where I am importing it.
Does anyone know why this is, and how I can fix the import, so that I can use the xyzToLatLonDegrees() method?
You need to have the CoordinateConversions class on your classpath. Either by obtaining the source and dropping it into your project (possibly adjusting package names, and only if the license allows), or by finding a JAR containing that class and adding it to your build path in your IDE.
You probably need to download the Java files from here.