Is there any method to count shared libraries (.so) programmatically. for example example.apk/lib/arm64-v8a/exp.so
i just want to count how much.so files is there in lib folder inside .apk file
Related
Surely there will be an answer to my question but I've been trying for days and I can't in any way.
This in the picture is the structure of my target folder. I would like to make the folders: image and video not be placed in the .jar file once the file is built but be placed as external folders in the same location as the .jar file.
However, I would like the folders to remain in the target file to allow me to access them via class.getResource during the test phase but once I have obtained the .jar file I have to be able to change these images at will and I don't want them to be present inside the .jar.
I hope I made myself clear.
I tried something inside the project structure but with no result
Structure folder
I'm currently working on a java library (binding) which uses some own written native code. This native code is compiled as a .so file for multiple architectures (arm-v7, i686, x86-64, etc).
I know in android you have to create a folder called jniLibs with subfolders for each architecture containing the proper .so file. Then with an Android.mk file and System.loadLibrary I can include these files into my code.
However, I have no clue how to include these .so files in a normal java project/library. I have read online that System.loadLibrary only works for looking through normal files (and not necessarily project files).
You can't have anything other than code in an android .jar file, however, you can have resources in an .aar file.
Android Archive Library (aar) vs standard jar
You will find that the .aar for your library is the redistributable/reusable compiled version of your library.
You can do it as how SWT did it -- extract the library files from your .jar file to user's home directory (so you are sure you have access to write in it) manually by java code.
You can check the source code of org.eclipse.swt.internal.Library, method extract().
Using eclipse, exporting a runnable jar file is pretty simple when I'm only using the application on my computer. Any files that the program is using (sprite sheets, audio tracks, etc.) only exist on my computer, so sending solely the jar to another machine won't work.
What is the easiest way to package a jar along with all the necessary files so that I could run the program on any machine?
I see from your tags that you are working in Eclipse. I am not sure if this method will work in other IDEs and I don't think it'll work at all if you're doing everything manually (it relies on the compiler automatically copying resources over to the bin folder.
The simplest way (at least what I use) is to define another sourcefolder (I like res).
Then you can just add packages to this source folder and dump the relevant images. Then rebuild your project.
Finally, you can use getClass().getResourceAsStream("package/path/file_name.whatever"); to get your files.
After an export as jar, it should work, even on other machines.
If you don't require the other files to be actual files on the file system (which means you can't use File, FileInputStream, etc) then you can use the resource system. If you put them inside the JAR, you can access them like this:
InputStream fileStream = SomeClassInYourJarFile.class
.getResourceAsStream("/path/to/file.png");
This example would give you an InputStream reading from the /path/to/file.png entry in your JAR file - that is, the "file.png" file inside a folder "to" inside a folder "path".
This does not require the files to be in a JAR file - it can load them from wherever your .class files are stored, JAR or not. If you put them in your source folder, Eclipse will automatically copy them to that place - so the above line would also work if you had a package path.to containing a file called file.png.
I would like to "dump" or "unpack" a library project's files into the main project, which would let me customize the library's contents for that project. Is that possible, and what is a way to do so? Can I just copy the entire library project's src/, res/, and manifest file into the libs/ folder of the main project?
(Please note that I do not want to touch the files from the original library project because I have other projects that are using it.)
If your library is a .jar containing .java source files, then you can unpack it using, eg. unzip, and move the contents of its src and res directories into your project's src and res directories.
If, however, this library contains only compiled Java .class files, there's not much you will be able to do with them. Unless you want to try to decompile them, the library must be used as-is.
I think that is better change the project name of the library and make a copy of this. This allow you to modify the files and dont mix it with your actual project.
When I clean and build a project in NetBeans, the .jar file appears in the dist folder, like it's supposed to. But what if I have multiple files under the project? What happens to those files? E.g. I have a Game project, and under it are the different characters(knight, rogue, etc.) but I only see a game.jar file when I clean and build, I want to know what happens to the individual files. Thanks
Those files should be in the jar file as compiled .class files. It's easy to double check what's in the jar file since it's in zip format. You can use a program like 7-Zip to open it, or rename it to the zip extension (e.g. from mygame.jar to mygame.zip) and whatever OS you're using probably has some way to open it.
When you open or extract the jar file you'll find the compiled class files in a directory structure that reflects your package structure. For example, if you have Knight.java in the directory src/game/characters/Knight.java in the jar file you'll find something like classes/game/characters/Knight.class.
The name "jar" is an abbreviation of "Java archive". It stores all the classes and other resources (for example, images) in a project.
The classes you have defined in .java files will be compiled into .class files - these are contained in the .jar file.
All resources get compiled into the JAR file. If you want a separate JAR for the resources, you'll need to split the project into two maven projects: one jar for the code, one for the resources. You can then create a third project that would generate a distribution.
That's a lot of work, though. It's.a lot easier tO keep everything in one JAR unless you have explicit dynamic loading requirements.