I have developed a C# application in Unity for Android. Additionally, I built a custom external C++ DLL which is properly loaded and accessible from the C# code. I have also added some .xml files into the StreamingAssets folder which works as expected as I can see those files loaded into the .apk.
Currently my problem is that I'm not able to access such xml files from my C++ library. On one hand I'm not sure how to do it correctly, on the other I tried multiple unsuccessful approaches including trying to understand in which cwd was my DLL loaded and then navigate to the files I needed (which didn't work as I constantly receive an access denied error).
EDIT:
Your replies actually put me on the right track and I solved the issue as follow:
During the OnStart() phase of my application, I use the UnityWebRequest class to extract from the JAR file the required files and then I save them in the Application.persistentDataPath
After that, I pass to my DLL the new path to each file which allows me to access them without any issue.
On Android the StreamingAssets are in a jar. That may well be the reason why you can't access them, but as you can see in the manual you can use the WWW class to retrieve files there.
On Android, the files are contained within a compressed .jar file
(which is essentially the same format as standard zip-compressed
files). This means that if you do not use Unity’s WWW class to
retrieve the file, you need to use additional software to see inside
the .jar archive and obtain the file.
(https://docs.unity3d.com/Manual/StreamingAssets.html)
On Android, the files are contained within a compressed .jar file
(which is essentially the same format as standard zip-compressed
files). This means that if you do not use Unity’s WWW class to
retrieve the file, you need to use additional software to see inside
the .jar archive and obtain the file.
A JAR is a package file format typically used to aggregate many Java class files and associated metadata and resources into one file for distribution. JAR files are archive files that include a Java-specific manifest file. They are built on the ZIP format and typically have a .jar file extension.
This means that you can work with jar files the same way as you do with zip files.
There is a fork for minizip with examples on how to use it.
I want to import a script that uses Dlib. Problem is that it won't compile without .dll file of Dlib.
Is there any way to get it into my project?
I have .lib file but I don't think there is a way to convert that to .dll.
#ali I made a make file of the dlib file using c-make and then used visual basic to compile it but in export setting I changed the. Exe to. Dll
I used apktool to extract an APK file contents. But for some reasons I need such a tool written in .NET so I do not need to install the JDK in the server.
Is there such a tool?
No. There is no such a tool. You need to start a Process in C# and run the batch file with the arguments using ProcessStartInfo class
I think in another approach, take the APK file and create a Java program that extracts the info I need such as package name, icon resource etc... and then expose it as COM object and use it in my .NET project.
After deep research we can not extract that info in standard functions in Java, since the only way to extract the info is to unzip the APK via the APKTool and read the manifest from the file system.
Another way but hard is to write your own extractor which involves in deep knowledge in the format of the APK.
Im looking for an example of how to decompress a bz2 file. I download the file via a control flow in an SSIS package, I would like to kick off a Script Task using some C# code to decompress the downloaded bz2 file. It doesn't seem that the decompression library that comes with .net handles bz2 files. Could someone show me an implimentation that could? or direct me to an example of decompressing a bz2 file to a specified folder?
SharpZipLib is what you're looking for.
#ziplib (SharpZipLib, formerly NZipLib) is a Zip, GZip, Tar and BZip2 library written entirely in C# for the .NET platform.
7-zip comes with bzip2 support (and many many more formats) and a C# wrapper.
I am learning Java these days and I've spent a lot of time with .NET so when I want to export or import libraries, they are usually in .dll format which is called assemblies in .NET environment and they are compiled to IL and they can have resources like images, XML, audio and so on, anyways.
I am wondering the same process in Java as well. I've read documents but they actually confused me a little bit and to clarify things out I need your help guys.
Questions:
.NET Assembly is the same thing as Java .jar?
.dll contains compiled IL code and .jar contains compiled .class/byte code files?
They say resources, what kind of resources we are talking about here? Images, .txt files, etc. or all of them possible?
I've examined AWS (Amazon Web Service API for java) and I saw three .jar file and they are
aws-java-sdk-1.1.1.jar
aws-java-sdk-1.1.1-javadoc.jar
aws-java-sdk-1.1.1-sources.jar
and they contain .class files - java documentation in html format and .java files which are still not compiled. So then I've realized .jar doesn't just include compiled byte codes (.class) and also other things.
When I want to import java libraries, will I always need to import .jar files?
When I want to export my own java libraries, should I need to export in .jar file.
Thanks for help in advance.
Is a .NET Assembly the same thing as a Java .jar?
They play the same role, yes.
.dll contains compiled IL code and .jar contains compiled .class/byte code files?
Yes. Although JARs are just zip files (you can open them in your favorite Zip tool), so they can really contain just about anything.
They say resources, what kind of resources we are talking about here? Images, .txt files, etc. or all of them are possible?
Any file type is allowed in a JAR. Your Java code can access the contents of files within the jar via, for example, getResourceAsStream or getResource. Obviously .class files in a JAR are treated specially (as bytecode).
I've examined AWS (Amazon Web Service API for Java) and I saw three .jar files and they are: aws-java-sdk-1.1.1.jar, aws-java-sdk-1.1.1-javadoc.jar, aws-java-sdk-1.1.1-sources.jar
The above packaging is fairly common. Sometimes people use .jar as an alternative file extension to .zip. I find this practice confusing, but it is not uncommon, and Amazon has done it in this case. I think this practice became more common with the launch of Maven, which stores reference source code in files named .jar.
aws-java-sdk-1.1.1.jar - This is the only file necessary for compilation and execution. It contains the classes (.class files) and resources necessary for the library to function.
aws-java-sdk-1.1.1-sources.jar - This is just a zip file that contains the source code (.java files) for the library. It is not necessary for compilation or execution. It is provided to help you troubleshoot problems you may encounter while using the library. You could unzip this file and read the source code from your hard drive. However, your IDE can probably utilize this file directly by creating a "source attachment" to the main library JAR. With this library->source association set up in your IDE, your IDE will be able to show you the source code of the library when you use your IDE's "Go to Definition" feature on a library class.
aws-java-sdk-1.1.1-javadoc.jar - This is just a zip file that contains the JavaDoc for the library. Again, it is not necessary for compilation or execution. JavaDoc is just HTML, so you could unzip this file and read the JavaDoc HTML directly from your hard drive. However, most IDEs can create a "Javadoc attachment" to the main library, which allows you to pull up context-sensitive JavaDoc for the library from within the IDE. Actually, most IDEs can generate the JavaDoc on the fly from the -sources.jar, so I rarely use Javadoc jars anymore.
When I want to import Java libraries, will I always need to import .jar files?
It's usually called "adding JARs to the classpath", but yes. You pretty much always need to help Java find all the JARs you're using by constructing a classpath whenever you build or execute. In general, using JARs and classpaths is a much more manual and explicit process than using DLLs in .NET. For example Java has no direct equivalent of .NET's "global assembly cache"; also vanilla Java will not automatically load .jars from the working directory.
There are a few other techniques for creating a more "automatic" feeling classpath, but they are kind of advanced: Manifest.MF classpaths are possible, for example -- but this approach is used infrequently as it is brittle. As of Java 6, Java has limited support for using wildcards in the classpath.
When I want to export my own Java libraries, should I need to export in .jar file
This is standard, yes.
I can answer part of that question :-)
As I understand it, a jar is just a "Java Archive" file. It can contain anything you want, but is most often used to distribute binary versions of libraries. It can also be used for distributing executables -- double-clicking a JAR file will launch the application, if that's how it's been packaged.
As such, it may be difficult to tell what a particular jar file is intended for. For example, what is aws-java-sdk-1.1.1-sources.jar?. Is it a self-installer? A compressed code archive? Without reading documentation, it's anybody's guess.
Edit: case in point, I just downloaded the JAI jar file assuming it was a binary build of the library. But in fact, it contains the installer application.
To answer this specific question.
aws-java-sdk-1.1.1.jar
aws-java-sdk-1.1.1-javadoc.jar
aws-java-sdk-1.1.1-sources.jar
The 1) is the compiler java archive file (jar), which in .NET is called a DLL. The 2) is the javadoc. An HTML documentation of java classes (found in 1)) along with method description. The 3) is the source code (java files) of 1).
When I want to import java libraries, will I always need to
import .jar files?
When I want to export my own java libraries, should I need to
export in .jar file.
For 1) If you need to use a class that is found in a jar file, then you'll need to import that jar into your project.
For 2) You don't need to. You can bundle your dependency jars into your library or package each into their own jars and import them into your project.
.NET Assembly is same thing as java .jar? Answer: Yes.
.dll contains compiled IL code and .jar contains complied .class/byte code files?
Answer: .jar files is an archived file of java resources, classes, images/icons/etc. that is necessary for an application, just like in .DLL. Class files contains compile java source codes (Called java bytecode).