I'm trying to setup the Scichart libraries using this guide.
The library I downloaded has a structure that looks like this:
I copied the 5 .aar files and the 4 documentation .jar files into the libs folder of the app in Android Studio, like so:
Following a guide I read online (I've never added an external library before) I found that for the documentation to work I'd need to add it as an attachment here:
However, when I right clicked and went to library properties it looked like it already had it - I assume that since the files are in the lib folder in the app they're seen and used.
So, everything should work. The problem is that Android Studio is offering to import one of two classes with the exact same package name but different Gradle packages (? don't know if that's the right term) on the right. Picture:
Why is it doing this? What did I do wrong when adding the library?
Per tutorial (Tutorial 01), the sections
Using Maven (well it's more Gradle)
Using bare SciChart libs
Are mutually exclusive.
If you already referenced their libraries via build.gradle (as described in the tutorial, Using Maven part), you don't need (and don't have) to put JAR(s) inside any folder and then add them to the Module settings, or whatever. Even sources will be pulled down automatically.
What you're doing is creating a local repository, in addition to using the remote one. That's why the duplicated libraries.
Related
I am working with a NetBeans project that has multiple packages. I will call them package_cam, package_demo, and package_drive. Inside of package_drive I have a class that requires a face recognition SDK that is a JAR and is clearly loaded in my libraries. However, when I run this file, I receive an unsatisfied link error stating that the sdk jar cannot be found. As I stated before, it is listed in my libraries and exists in my lib folder in the project folders. I have searched high and low in Netbeans trying to find a location where that lib must be specified but have come up short. Has anyone ever run into this before? Is there a reason that a certain package would not be able to see or use the library? I am importing the sdk at the head of the file with this
import Luxand.*;
import Luxand.FSDK.*;
import Luxand.FSDKCam.*;
Any help with this would be greatly appreciated!
(I assume you use Netbeans 8 from the question tag, and your project is Ant-based)
In general the recommended way is to use a library wrapper module. There is a wizard so it's very easy, menu File > New Project > NetBeans Modules > Library Wrapper Module. More details in these Netbeans FAQ entries: http://wiki.netbeans.org/DevFaqWhenUseWrapperModule and http://wiki.netbeans.org/DevFaqWrapperModules
If you don't use a wrapper module, you should update project.xml to add the library to the class path, for example:
<class-path-extension>
<runtime-relative-path>ext/hexedit.jar</runtime-relative-path>
<binary-origin>release/modules/ext/hexedit.jar</binary-origin>
</class-path-extension>
See this other FAQ entry: http://wiki.netbeans.org/DevFaqHowPackageLibraries
I would like to use the following module (https://github.com/intrbiz/hs110/blob/master/src/main/java/com/intrbiz/iot/hs110/HS110Client.java) in my app to control a TP-Link smart plug but cannot figure out how to get it done. I managed to add the dependencies for fasterxml/jackson dependencies but searching the dependencies for "com.intrbiz.iot" did not return any matches so I guess I need to copy and integrate those files locally but I am not sure how to do that (each function in the HS110Client.java file is defined in a separate .Java file (e.g. HS110Response.java, GetRealtime.java...etc.).
Any help would be much appreciated :)
Thanks!
Gaetano.
Nice work on jarring up the project. I cannot go into all the specific details on this post but I can try to guide you in the right direction from here. Try to view the .jar as an artifact that you will use in your codebase. 2 options from here are listed below, google each one as you will find many articles to help you figure it out.
Add the .jar file to your build path manually (usually something like right clicking your project in an IDE -> configure build path -> add dependencies)
If your using Maven (very common in todays development world) you can convert the .jar into an artifact and include it in your pom.xml
In my case I use maven, once you get the dependency in there your IDE might look something like below, note the "maven dependencies" section, it basically lists all the .jars in my project that I can consume.
Once you get the .jar in your project correctly the source code should become usable. Most IDE's use a hotkey as ctrl+shift+t (open type) that allows you to search for classes, if you can do that and see the classes from the .jar your built, you should be able to simply import them into any class your working on and use it directly.
Note: If you are using maven another thing you should check is if this project your consuming is already in the maven central repository, if it is, you can just add it to your pom.xml and your good to go.
Good luck and hope this helps!
I created a project but I am using an external library for it. enter link description here
I added the library to my Beans as follows:
Right click on folder "Libraries"
Add Library
Create...
Gave it a name "gson 2.7"
Picked the class, source and javadoc files.
I went on and continued programming and then I added my code to Github. Then when I cloned it my Library was missing.
How can I fix this ? How can I make it dynamic so I dont have to worry about this anymore. In other words I need to add the library to my code and not just the reference.
Thanks a lot for the help
Just upload a copy of your library to github.
I have not used netbeans, but from what I understand it adds the jar somewhere outside of your project directory, and it simply adds the location of the jar to your classpath. When you upload and then clone the project from github, the jars are not uploaded/cloned, and the project structure metadata for your project is also lost from netbeans.
My suggestion is to learn and start using a build tool like maven. It takes up the responsibility of adding your dependency libraries everytime, given that you have an internet connection. It also adds the libs to the target directory of your project folder, so you probably will need the internet connection only once. The libs will be uploaded and cloned back from the github repo everytime.
IDEs like eclipse have inbuilt support for maven, so you don't even have to worry about executing the mvn commands. Here's a tutorial that will get you intrigued - with the IDE that you prefer.
https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html
Thanks a lot for all the replies and comments.
Technically there are two approaches to my problem. For this articular example I chose to copy the external jar files to my project.
1. Copy jar files to your project.
Go to project properties
Under Libraries folder make sure to set up a libraries folder by following the steps.
Add Library at the bottom ( you can create or import; since I already had gson in Netbeans I just imported it.)
Press ok to confirm and you are done!
2. Use Maven
Go to plugings and make sure you have all Maven plugins installed, if not do so.
Create an new project and choose maven/java application
Follow the prompts
At this point you can start coding (in my case I just imported my class files from the other project)
Right click in "Dependencies folder and then "Add Dependency"
Under query type the repository you are looking for; in my case "com.google.code.gson : gson : 2.7"
Click add and you are done!
Thanks a lot to everyone for the help :)
I'm working on an android game that requires a server. We've set up a git in which there are three folders: Client, Server and Shared:
Client contains the Android-Studio project.
Server contains an Eclipse project which is our server and database.
Shared contains java classes that I would like to use in both the Eclipse and Android-Studio project.
In Eclipse I successfully loaded the files from Shared by importing them as "file system". (It created a package and everything works great)
In Android-Studio, I can't find a solution that doesn't require me to copy-paste the classes in the project. The aim here is to have those file at only one location as they're susceptible to change but must me identical in both the projects... So those solutions don't fit my needs.
I'm looking for something like a way to link files from outside the project. (I managed to link libraries from inside the project already but not from outside)
The simple solution is to copy the desired java files into your project structure. Of course, you may have to change package names manually.
Found a solution that might not be optimal but at least in my case it solved the problem.
In Android-Studio:
Create a folder called something like "CommonEclipseAndroid" following a path similar to this one: project/Android/app/src/main/java/com/example/myapplication/CommonEclipseAndroid
Paste the code you need to use in both project inside this folder.
In Eclipse:
Right click on your project: Properties > Java Build Path > Source > Link Source and choose the folder we've just created.
Now your projects use the same code. You only need to modify it once for both projects and there's no risk of error.
Hope I helped :).
You can import the shared folder as a module .
go to file> new> import module
Now use the same imported folder in eclipse as well.
Ok so there are tonnes of API's out there. I need to use some of them like JIntellitype, iText, docx4j etc. But the problem is I do not know how to go about it in Netbeans.
I tried following the instructions in readme for all these API's but it does not work since there is something I am doing wrong. I am a newbie at JAVA and Netbeans.
Thanks!
[Update]
This is what I tried to do.
I downloaded the JIntellitype API. It contains lots of files including JAR,DLL,CPP etc. When viewed through File->Open Project from Netbeans this folder is displayed as a project.
I created a new JAVA Application project from Netbeans.
I right clicked the Project->Properties->Library and added the API folder there.
Then I tried importing one of the classes from the API called HotkeyListener as follows:
import jintellitype.HotkeyListener;
I received an error saying package does not exist.
Generally you have to add your API jar to your project. Open project properties, find where external libraries are added and add them. Once you are done you can import library classes and use them.
like AlexR said, you should add the jar file with the jintellitype.HotkeyListener in it, not just the directory. You can open jar files with winrar, winzip, 7zip etc...
Regards