I'm new in android, and I want to import the jfftpack to my project in android studio anda i don't know how to import it.
The original code was import ca.uol.aig.realdoublefft and I'don't know where to put the java files. I've tried to put them to a libs folder.
here's the jfftpack source code:
If it's an existing code library, I'd recommend adding a module for it. Probably the easiest way is to use the File menu command to add a new module, let it create a plain Java (non-Android) module for you, remove the sample class it puts into the module, and then copy your files over into it and tweak it. The module wizard will take care of setting up the directories and build files for you, and you can look at it later and see what did.
Without pressing Alt + enter to import the Packages?
There is some steps like
1)File --->Settings --from left pane we find editor---->General--->Auto Import
There
Insert imports on paste as ALL not ask
And put check mark for all the Above three Fields
1)Show import popup
2)Optimize the imports on fly
3)Add unambiguous imports on the fly
Click Apply and ok
Happy Coding......
If you have the sources import them in the src folder. Is the simple thing that you can do.
I suggest you to use the command line rather than Android Studio interface.
If you work on Linux or MacOS, try to copy the package to your working direcotry like:
cp -r PACKAGE_NAME PATH_TO/AndroidStudioProjects/PROJECT_NAME/app/src/main/java/
I am also new and had the same problem. I didn't have the package instruction at the top of the java file package com.example.myapp
Related
I am using Eclipse IDE for Enterprise java and web developers. I downloaded some zip file called facts(1) and followed every step in setting up this facts project. When I try to run it on server it showing " ... doesn't match the expected package. I tried by adding import package facts; and also without that! I have also looked similar answer and didn't able to fix that either. FYI i have jdk (16.0.2) currently.
[enter image descripenter image description heretion here]2
enter image description here
As you are using default package for your facts classes like Fact.java, FactList.java, you do not need to import it.
However, I think your fact files Fact.java, FactList.java, etc are also failing compilation as the package declaration on those files are not same as the folder structure.
So please try these:
Make sure that there is no statement
package xxx.yyy.zzz;
in your fact classes Fact.java, FactList.java, etc and they are compiling successfully i.e. no errors in those files.
Remove the import statement in FactServlet.java as it is not required.
But.. according to Java standards using default package is not advisable. Create proper directory structure for your files.
you classes Fact.java, FactList.java, FactSearchModel.java and few more are in default package
create a package and move these classes to package, then import that package wherever required
I'm trying to use this library called OpenSimplexNoise, made by GitHub user TheCodingTrain. But I immediately discovered that I couldn't use it.
I did some digging to try to figure this out on my own, and I discovered that the JAR file and the main folder should have the same name (for example, the library file would be named OpenSimplexName and the JAR file would be OpenSimplexNoise.jar), and the folder the JAR file is in should be called "library." Once I fixed these issues, OpenSimplexNoise appeared in the "Import Library" menu in the "Contributed" section. But once I clicked it, a bunch of code appears:
import japplemenubar.*;
import processing.awt.*;
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.javafx.*;
import processing.opengl.*;
along with the error message:
More than one library is competing for this sketch.
The import japplemenubar points to multiple libraries:
core (C:\Program Files\Processing\processing.3.5.4\core)
OpenSimplexNoise (C:\Users**\Documents\Processing\libraries\OpenSimplexNoise).
Extra libraries need to be removed before this sketch can be used."
I tried removing japplemenubar, but the same issue appeared with processing.awt, so I tried removing that, but it just kept happening with each different import. I tried deleting it all and just typing "import processing.OpenSimplexNoise.*;", but it said "The import processing.OpenSimplesNoise cannot be resolved."
Does this mean that I'm just doing something wrong, or is this library no longer usable?
I recommend watching/following the videos linked in the README and understanding those:
https://youtu.be/pI2gvl9sdtE
https://youtu.be/U0TGZCEWn8g
The tutorials are how to put organize/compile a basic Processing library from scratch, not how to use library itself.
It would've been easier if a distribution zip would have been uploaded, but the point is learn how to generate it.
Downloading the library zip and unzipping in Processing won't work.
You need to:
(install eclipse if you haven't done so already as part of the video tutorial)
clone / download the project on your computer
Import the project into eclipse:
Drag and drop the build.xml file into the Ant panel: (in my view I've got multiple Processing libraries, you might have just OpenSimplexNoise)
Press the green Play Icon to run the build.
Initially I ran into this error:
BUILD FAILED
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:107: The following error occurred while executing this line:
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:141: /Users/George/Desktop/OpenSimplexNoise-for-Processing/lib does not exist.
Instead of trying to debug/fix the xml file I simply made the folder structure it wanted: a desktop folder named OpenSimplexNoise-for-Processing containing a lib folder.
Smooth sailing after this: BUILD SUCCESSFUL
Part of the ant build is copying the library to Documents/Processing/libraries so you can simply run the examples from there:
FWIW I've uploaded the compiled library here.
If simply wanted to use noise in Processing the built-in noise() function would do the trick.
If you want Simplex Noise without compiling Daniel Shiffman's example library you could try toxiclibs and it's toxi.math.noise package (also comes with an example sketch).
I'm kind of new with Processing 3.*; I am (and willing to) using the Processing Development Environment (The official IDE).
Reading the official "guide", in particular this part, it is specified that you can use pure Java language inside Processing simply naming a .java tab instead of a .pde one.
This kind of solution is good for example to use enums (otherwise not usable in .pde tabs) and there are other reasons, but they are not important at the moment...
A problem with this kind of work is that the libraries of Processing are not included, so you have to import them manually.
What I noticed is that all the official Processing libraries can be imported simply by the import keyword, while for all the libraries installed by the Contribution Manager the story is different.
The error message is The package "packageName" does not exists. You might be missing a library. Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.
Long story short I can't import those libraries...
I tried to copy them in the standard java libraries location (%SystemRoot%\Java\lib\ext) and in some other paths, but nothing...
I read that using classpath would allow as to use it but I can't understand how to use Processing with javac.
I also tried something like "ProcessingFolder\processing-java.exe" --sketch="$(CURRENT_DIRECTORY)" --run that is the same script you can use to run Processing in Notepad++, adding the statement --classpath="$(CURRENT_DIRECTORY)" (Obviously in Notepad++) but it didn't work (processing-java.exe state I don't know anything about --classpath=.).
So here's the question: How can we import and use libraries in .java tabs using Processing Development Environment?
That doesn't sound right. You should be able to use library classes just fine by importing them in a .java tab.
Step 1: From the PDE, go to Sketch -> Import Library, then choose the library you want to include. Notice that if you haven't included a library before, it's actually two steps: first you have to install the library, then you have to include it.
Step 2: Once you've included a library in your sketch, you can use the classes from that library anywhere in your sketch. This includes .java tabs.
Here's an example that uses the minim library in a .java tab. I didn't have to copy any files or create any directories:
Main sketch tab:
void setup(){
Test test = new Test(this);
}
Test.java tab:
import processing.core.PApplet;
import ddf.minim.Minim;
import ddf.minim.AudioPlayer;
import ddf.minim.AudioInput;
public class Test {
Minim minim;
AudioPlayer player;
AudioInput input;
public Test(PApplet sketch) {
minim = new Minim(sketch);
player = minim.loadFile("song.mp3");
input = minim.getLineIn();
}
}
It sounds like you aren't properly including the library in your sketch. Make sure you go through the Sketch -> Import Library menu, and make sure you both install and include the sketch.
I am trying to import and use PDFBox, but am having issues installing the jars I believe.
I am using Dr. Java, and I have added both the pdfbox-1.8.6.jar and the pdfbox-app-1.8.6.jar to my resource locations in my Extra Classpath.
However, it still is not recognizing the jars when I run the code:
import org.pdfbox.cos.COSDocument;
import org.pdfbox.pdfparser.PDFParser;
What other steps do I need to do in order for the jars to work?
Use the correct imports:
import org.apache.pdfbox.cos.COSDocument;
import org.apache.pdfbox.pdfparser.PDFParser;
Additional hints:
pdfbox-app-1.8.6.jar contains the classes from pdfbox-1.8.6.jar, so you don't need pdfbox-1.8.6.jar too
if you want to load a document for rendering or text extraction, you won't need these two imports. Loading is done with
import org.apache.pdfbox.pdmodel.PDDocument;
PDDocument doc = PDDocument.loadNonSeq(new File(filename), null);
To see how it is done, look at the examples in the source code. Good luck!
Have you tried the steps detailed on the documentation:
Adding And Removing JARs in DrJava
A JAR file is a way of storing many (pre-compiled) Java classes. Below
are instructions for adding and removing jar files from DrJava's
resource locations. For more information on JAR files, see our JARs
page and Using JAR Files: The Basics on Sun's site.
How to add a JAR
When you download the jar, keep track of where you save it to
Open DrJava
Edit > Preferences
Resource Locations (at left)
In Extra Classpath, Add (browse and chose the new jar)
Apply
Okay
Quit DrJava and re-open it in order for the change to take effect
This is probably very simple, however I can't get this to work. I want to use AbstractDependencyInjectionSpringContextTest class which is in org.springframework.test package. This package is not included in Netbeans' spring library, so I want to add it. So what I have tried so far is:
copy and paste "test" directory (downloaded from spring) into the Netbeans' spring-2.5.6-SEC01.jar file (copy it to org.springframework directory in that jar so I can use org.springframework.test to import it). If I go to project/libraries in Netbeans it is there, but when I try to import org.springframework.test.*; the autocomplition doesn't give me the option to choose test directory from org.soringframework package.
create a new library which points to "test" directory and add it to the project- as there is no any jar file in "test" I'm not sure what path should I use to import it.
I'm pretty sure this is something very simple but I'm still a novice and can't figure this out.
According to grepcode, the test package is not included in spring-2.5.6-SEC01.jar. You need to download spring-test-2.5.6.SEC01.jar.