Importing JTransforms library - java

I downloaded and compiled JTransforms-3.0 into my project and I can see it in the hierarchy here:
I'm running into issues on when I try to import it.
import edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D;
It says it cannot resolve the symbol "edu" and I can get an error saying that the package doesn't exist. I'm using android studio and I have the libraries in my gradle file under the dependencies. Can anyone help? Thanks.

I don't know if you solve the problem still but I had to go through the same path as well. I ended up going to the Jtransform's GitHub page and downloading the "JTransforms-3.1-with-dependencies.jar" file. Placing it in the "libs" folder, right click "Add as a library" and works perfectly! :)
JTransform's github page

It should be imported like this:
dependencies {
...
implementation 'com.github.wendykierp:JTransforms:3.1'
}

Related

Importing the GSON library jar file into my project is not producing expected results

Hope you're doing well. I'm creating this simple app where you write text into a TextField and it should write it within a new JSON File in the resources folder. I'm pretty sure that my code is perfectly fine upon checking it with my professors, however, upon importing the library as seen here:
And executing the following code when the button is pushed:
*I have the following imports at the top of my JFRame class (The IDE shows no errors under those lines) :
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Gson gson = new GsonBuilder().create(); //<-- The error always comes from this line
I get the following error which I have no idea how to fix:
I have read that switching to a Maven project is an alternative but it's not recommended for my practical. Any solutions would be greatly appreciated. I must also further note that the jar file is located in my libs folder and it is there.
Many thanks!
Edit: They asked me how my program was executed and this is what goes into the compiler in vscode (I execute it in the Run -> Run without Debugging):
c:; cd 'c:\ContentBoxFinalPrac\ContentBox'; & 'c:\Users\ytobi\.vscode\extensions\vscjava.vscode-java-debug-0.32.1\scripts\launcher.bat' 'C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\bin\java.exe' '--enable-preview' '-XX:+ShowCodeDetailsInExceptionMessages' '-Dfile.encoding=UTF-8' '#C:\Users\ytobi\AppData\Local\Temp\cp_chdymt7vzhi9in94pnpo6ha1h.argfile' 'ui.HomeScreen'
I download gson-2.8.6.jar from Maven Repository, after adding it to referenced libraries, the code works well:
Please check if your jar misses some parts. Open command palette and choose Java: Clean Java Language Server Workspace then redownload the jar and see if question goes away.
The issue has been fixed for those still searching. I had to install this SDK which I was missing from VSCode -> Here https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-5.0.202-windows-x64-installer?journey=vs-code
and just create a new project in the left hand bottom panel. Then import everything as you should and demonstrated by Molly Wang.

java: package does not exist error only after build

I'm trying to add the JCodec library to my android studio project. I followed the steps listed here. I import these four lines:
import org.jcodec.codecs.h264.H264Decoder;
import org.jcodec.common.AndroidUtil;
import org.jcodec.common.model.ColorSpace;
import org.jcodec.common.model.Picture;
I get no errors until I build my project. When I build the project, I get an error that each of the packages I tried to import don't exist. Does anyone know what the problem is?
Thanks!
I did not really understand how linked answer helped you to add library because it is for Eclipse and you are using Android Studio and Gradle.
In build.gradle you should add:
dependencies {
...
compile 'org.jcodec:jcodec:0.1.9'
...
}
I figured out my problem. The issue was that I added the library under libraries but it wasn't a jar file, it was an android project. What I did to solve the problem was adding it as a module and then adding the module as a dependency to my project.

Many "cannot be resolved to a type" errors when opening CoGroo project

i'm trying to import a CoGroo project, but i cannot do that. Then i try to import i press File>New>Java Project> un-check User Default Location (Eclipse Luna) > Search the folder "cogroo-4.0.0-src" and all the project are inside of that> then when i open my project a lot of "x" stay in the folders and in the projects! what should i do? someone help please!!!
image of when i try to Run it!
i have already tried to import and run this sometimes
[enter image description here][1]
then i try to "import" and i recieve that image!
[2]: http://i.stack.imgur.com/W1HZc.png
That is a multi module project. You should add all subprojects to eclipse using "Import...".

net.java.util.tagValue : Not resolvable

In my program, I am trying to import below classes but there comes a compile time error for this. Am I missing any jar there ? If yes, then which jar I am missing. Please help me.
"import net.java.util.TagValue;"
I am writing this in eclipse
A simple search on the net shows that net.java.util.TagValue class belongs to fixparser library. Make sure that this library is in your classpath when working on your project.

Eclipse error ... cannot be resolved to a type

I have a dynamic web project that I am working on to migrate a jsp/servlet app from JRun to Tomcat.
I am getting the error: com.ibm.ivj.eab.dab.DatastoreJDBC cannot be resolved to a type.
I have the *.class files sitting inside a com/ibm/ivj/eab/dab folder (exactly how I found them). I have tried creating a jar file and adding that to the build path via "Add External Jar", I have also tried adding an "External Class Folder" and pointing to the folder that contains the "com" directory in question.
Still, the error persists. What is strange is if I start typing the package name eclipse actually auto-completes the class for me! (pictured below). Any ideas would be greatly appreciated. Maybe the classes were compiled for a much older java version and that is causing trouble? Maybe there is something I need to do to ensure the classes end up in the WEB-INF/lib directory?
I
Also If you are using mavenised project then try to update your project by clicking Alt+F5.
Or right click on the application and go to maven /update project.
It builds all your components and resolves if any import error is there.
Right click your project name.
Click Properties.
Click Java Build Path.
Click on Add Class Folder.
Then choose your class.
Alternatively, Add Jars should work although you claim that you attempted that.
Also, "have you tried turning it off and back on again"? (Restart Eclipse).
To solve the error "...cannot be resolved to a type.." do the followings:
Right click on the class and select "Build Path-->Exclude"
Again right click on the class and select "Build Path-->Include"
It works for me.
There are two ways to solve the issue "cannot be resolved to a type
":
For non maven project, add jars manually in a folder and add it in java build path. This would solve the compilation errors.
For maven project, right click on the project and go to maven -> update project. Select all the projects where you are getting compilation errors and also check "Force update of snapshots/releases". This will update the project and fix the compilation errors.
Project -> Clean
can at least sometimes be sufficient to resolve the matter.
For maven users:
Right click on the project
Maven
Update Project
Easy Solution:
Go to
Project property -> java builder path -> maven -> find c3p0-0.9.5.2.jar
and see the location where the file is stored in the local repository and go to this location and delete the repository manually.
Right click Project > Properties
Java Build Path > Add Class Folder
Select the bin folder
Click ok
Switch Order and Export tab
Select the newly added bin path move UP
Click Apply button
Solved the problem by dropping the jar into WEB_INF/lib.
copying the jar files will resolve. If by any chance you are copying the code from any tutorials, make sure the class names are spelled in correct case...for example i copied a code from one of the tutorials which had solr in S cap. Eclipse was continiously throwing the error and i also did a bit of googling ...everything was ok and it took 30 mins for me to realise the cap small issue. Am sure this will help someone
For many new users don't forget to add an asterisk (*) after your import statements if you wanna use all the classes in a package....for example
import java.io.*;
public class Learning
{
public static void main(String[] args)
{
BufferedInputStream sd = new BufferedInputStream(System.in);
// no error
}
}
================================================================
import java.io;
public class Learning
{
public static void main(String[] args)
{
BufferedInputStream sd = new BufferedInputStream(System.in);
// BufferedInputStream cannot be resolved to a type error
}
}
Solution :
1.Project -> Build Path -> Configure Build Path
2.Select Java Build path on the left menu, and select "Source"
3.Under Project select Include(All) and click OK
Cause :
The issue might because u might have deleted the CLASS files or dependencies on the project
Project -> Build Path -> Configure Build Path
Select Java Build path on the left menu, and select "Source"
click on Excluded and then Include(All) and then click OK
Cause : The issue might because u might have deleted the CLASS files
or dependencies on the project
For maven users:
Right click on the project
Maven
Update Project
First you need to update the pom.xml by adding below
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
1] Right click your project name.
2] Click Properties.
3] Click Java Build Path.
4] Check on 'Maven Dependencies' in Order and Export tabl.
In my case, previously it was not enabled. So when I enabled it my #GetMapping annotation works fine..
Also, there is the solution for IvyDE users. Right click on project -> Ivy -> resolve
It's necessary to set ivy.mirror property in build.properties
I just closed all the files and reopened them, and voila!!! Hope this helps someone in the future ;)
Download servlet-api.jar file and paste it in WEB-INF folder it will work

Categories

Resources