Wrapping jar into a dll - java

I want to make a COM server packaged in a DLL for use from VBA-Excel.
The functionality will be provided by Java classes packaged in a jar.
How do I do this?

For calling Java code from Excel you can use Jinx, the Excel Java Add-In.
See https://exceljava.com for details.
Using Jinx you can write a full Excel add-in including user defined worksheet functions and macros in Java, without any need for COM or VBA.

Related

How do you share Java functions without giving others source code?

When programming in C++ we have header files and source files. When our company sells our product (which is just a library of useful functions essentially) we provide the client only our header files and compiled source code (not the actual source code). This way clients buying the code see the function definitions in the header files and can make calls to these functions using the compiled code.
How would a company who is developing in Java go about sharing their library functionality without giving out their code? Since there are no header files in Java is this just done through documentation; i.e, provide the client with an API document showing all the function signatures and also provide a jar file with the compiled classes?
In Java you don't need source code to compile against - the bytecode contains all the metadata you need.
So for example, if I create an interface with some methods in, compile it into a class file, then package that up into a jar file and give you that jar file, you can use that interface and see all it's members etc without having the source code.
Typically you'd also provide documentation to explain the meaning of the methods etc, but they're not required in order to compile against the jar file.
Take for example YWorks YFiles, they offer their proprietary lib but they do some obfuscation on their distribution(using their own obfuscator).
As for guidance how to use their lib, they ship their lib with javadocs, some howto documents and some sample code.

How to use external jar library in a SAP HANA XS project

I am trying to make an XS project in HANA which will use some of the classes and methods that can be found in a .jar file. These classes and methods will do some calculations and present it to the user in the UI.
The question is: How do I access methods and classes of that .jar file?
I have registered it as an external library, but I have no idea how to call it from my XS javascript source files.
there's no way to invoke external .jar package from XS's server-side JavaScript. You can use an external library using function "$.import", but this is only valid for JavaScript library.
XS Server does not and will not support Java. Only Javascript...
If you want to outsource some of your xsjs functions to an external library, xsengine provides a special format for this, called ".xsjslib".
You can import a library using the following code:
$.import("<package_your_library_was_deployed>","yourLib");
access functions inside your lib by this path:
$.path.to.your.library.filename.yourFunction();

From DLL to java classes

I have dll file which is controlling a device, I need a tool to generate java classes which take the dll file as an input and generate all the need JNI classes.
Note: I don't have the C,C++ code for that DLL.
I believe you are doing all this so that you can call C++ methods through Java.
Instead use JNA library. It does not require any explicit JNI classes to be built. You can directly call C++methods. Read more about it here

How can I run Excel Macro from Java?

I've .txt files generated by Java (with databases queries). I need to generate an excel with that (with graphics and other kind of information, is not just a pure csv).
How can I call my excel macro using java?
I would say, have your Excel macro use the csv as a data source and let it do it's job directly.
Otherwise you might want to look into a reporting framework like jasper reports http://community.jaspersoft.com/project/jasperreports-library
You need to use a JAVA-to-COM bridge, such as Jacob. http://danadler.com/jacob/ there are other out there but I am familiar with Jacob. Then you would be able to start the application, load the file, run the macro, and then close the application. This should get you started.
Why not create an excel directly using java apache poi, instead of creating txt and then converting txt excel using macro.

VBA/excel to dll/exe for Java

I have an Excel file with manual input functions, which use an add-in from a third party. I want to use the functionality of the Excel file in Java. I could think of two ways of doing it:
code the functions in VBA, or VB with Excel reference, then generate .dll or .exe files for Java to use.
Feed data to an Excel file using jxl (would Excel file update automatically when it receives new data?), then read the new result every time from the Excel file.
I don't have much experience with Excel or VBA. I want to know which method is more doable and faster.
As your code is invoking a third-party add-in and is needs that for correct operation, then you will need to go the VB route or access Excel via the Automaton API (from Java, using for example, Com4j).
The reason is that the pure-java excel readers (jxl, Poi, xlSQL etc..) all use java to emulate the built in functionality of excel, but of cousre they cannot emulate third party add-ons.
Reading excel files using com4j is discussed in this thread.
Obba allows you to make calls from an Excel cell to a Java virtual machine (which may run on a different computer, if necessary). The JVM has to run Obba server (provided as a Java with main() method). The Obba server can load other JARs an instantiate objects via functional calls form the Excel sheet.
You could also use Obba to pass values, results to a Java code (or server).
(You may contact me, if you are interested in exploring this and need assistance (I work on Obba).

Categories