How to import jar files in NetBeans - java

I am trying to build a very basic voice recognition application via a tutorial. I need to add sphinx4-core.jar and sphinx4-data.jar. I added them into my library and am attempting to import them into my code and I get a "package edu.cmu.sphinx.api does not exist" error. Here are my import statements:
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
To add the jar files I went to tools -> libraries -> add JAR/Folder

Related

Getting "The import xx cannot be resolved" while trying to run an existing project in eclipse

Please bear with my limited experience of working with Java.
I imported the project https://github.com/karantongay/Split-Large-Excel-File-into-smaller-excel-files-using-Apache-POI into eclipse.
On opening the file excelsplitter.java, I see The import xx cannot be resolved errors against all of the following -
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
I understand that the dependency jar could not be found. What is the easiest way to get this included and make me run this.
I know how to import an existing Maven project in eclipse but that's where my knowledge is limited upto.
As per the information provided above, one of the ways is to convert the existing project into maven projects which can be done using right click on Project -> convert into Maven project and then you will be having Pom.xml available in your project where you can add on dependencies.
For above issue, apart from maven stuff ,if you are using correct jar may be it’s on in the build path of the project.
In your eclipse just right click on Java Project and click Configure and you should see “ Convert to Maven Project ” option.
You should see dialogue like this below. Just add “ Name ” and you should be all set.
Don't forget to add your all custom dependencies in pom.xml file.

LibGdx Tools Error

I have problem with building my Core/Desktop/Android project in IntelliJ after adding gxd-tools.jar as Core Library.
Please note my imports:
package com.enplug.exampleapp;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.enplug.common.logging.ILog;
import com.enplug.sdk.hosting.AppState;
import com.enplug.sdk.hosting.HostedGame;
import com.enplug.sdk.interfaces.FontType;
import com.enplug.sdk.interfaces.IServiceProvider;
import com.enplug.sdk.model.social.SocialFeedDefinition;
import com.badlogic.gdx.graphics.g2d.freetype.*;
import com.badlogic.gdx.tools.imagepacker.TexturePacker2;
and TexturePacker code:
TexturePacker2.process("C:\\pokusatlas", "C:\\pokusatlas", "spritesheet");
Screenshot of my error:
What should I make to avoid this error?
Check the guide about adding libgdx tools to the gradle dependencies. Let me quote the important part:
Tools Gradle
Core Dependency:
Dont put me in core!
==> you should not add gdx tools to core project! Put it in desktop project instead:
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
The issue with adding libgdx-tools to core project is that the libgdx-tools are not compatible with android/ios projects. But android/ios depend on core project, so you cannot add plattform-dependent libs to your core project.
But even if it would be possible to include in core project it wouldn't be a good idea either. I mean you are not going to run TexturePacker in your released apps anyway. Just run TexturePacker during development and include its output in your android assets folder.

build path entries are missing

I have copied my project from one system to another,now I am trying to run it,I am having a message in build path that 95 build path entries are missing. I am having main problem with importing some packages like:
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;
import org.krysalis.barcode4j.BarcodeDimension;
import org.krysalis.barcode4j.HumanReadablePlacement;
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.impl.upcean.EAN13Bean;
import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;
import orgimp.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.SubstanceSkin;
if you are using eclipse ,then right click on project
Properties->java build path
now check source all class file src is added or not,
check libraries that all necessary jar is added or not
if yor are running through comand prompt then you need to set path in command line
right click on project
go to properties-->java build path--->Libraries
add all library that needs in your project
and also check your java compiler
go to properties-->java compiler
choose necessary java compiler
------------------------------- OR ---------------------------------------------
it may be possible that required jar files are not present in your lib folder
Try deleting those entries from build path (make sure you leave the jars which eclipse already can find).

file to import not found. Import of other files works

I have a really strange problem.
I want to import two files which are in the package soap. But Eclipse doesn't "see" the files if I want to import them. Even if I change the directory of the file to a package, in which Eclipse sees the other files and is able to import them, these two new .java-files won't show up to import. Even if I try to import it "by-hand", Eclipse doesn't find them:
import ch.asdf.soap.DocumentReply;
import ch.asdf.soap.DocumentRequest;
I've also tried to import the whole package:
import ch.asdf.soap.*;
There aren't any errors in the files.

I have downloaded geotools . In which eclipse directory should I put it in for it to be fetched by my java file?

package geotools.data.geojson;
import jts.geom.Coordinate;
import jts.geom.CoordinateSequence;
import jts.geom.Envelope;
import jts.geom.Geometry;
import jts.geom.GeometryCollection;
import jts.geom.LineString;
import jts.geom.MultiLineString;
import jts.geom.MultiPoint;
import jts.geom.MultiPolygon;
import jts.geom.Point;
import jts.geom.Polygon;
import jts.geom.impl.CoordinateArraySequence;
So where should jts and geotools go into for me to be able to access them ?
There is an eclipse quickstart that answers your question; it provides instructions for both use of maven (which is more automatic); and for downloading the jars into a usable eclipse project.
http://docs.geotools.org/latest/userguide/tutorial/quickstart/eclipse.html
The eclipse download includes JTS (and other support libraries as needed).
It should be added to the project's build-path if it's a JAR file.

Categories