Calling something written in Java

In theory, if someone has some Java code, could they create something which I could call as a helper in Windows and OSX to perform a file format conversion?

eg shell out to helper.exe with 2 filenames?

(Ive been given some Java code which I cannot follow, and need to pay someone to either translate it into Xojo, or write a module in Java that turns X into Y)

https://www.monkeybreadsoftware.net/plugins-mbsjavaplugin.shtml

2 Likes

Thanks - but I think that missed the part about me not understanding what the Java code is doing… :slight_smile:
I suppose Im asking if Java can compile to a stand alone thing, or do I have the wrong idea completely ?

Java requires every running client machine to have java installed. Same a python requires python to be installed.

So it’s not 100% stand alone

1 Like

So I guess what I really need is someone who understands Java, to translate code into Xojo.
Do we have anyone here?

Java is not hard to understand. the problem is if it used librarys that you not have.
so java need a runtime install. then a exe is called for the bytecode in jar file.
more a less a command line tool. see https://netbeans.apache.org/
java / oracle have also a online manual for her framework. a OpenJDK exists too.

if your java source code not have dependencies its possible to convert it to xojo.

Like Python you can make apps out of Java code. Don’t ask me how this is done. But my favourite app is a Java app.

btw
java<>java script

It can be compiled to a JAR file, but as noted, you’ll need a Java Runtime Environment (JRE) on the user’s machine to execute it. This is fairly common, and easy enough to point a user to a JRE installer if they don’t have it.
The second issue is whether the code is exposed in such a way that it can be run from a command line or it’s just a pure Java library function. If it is the first (it’s already encapsulated as a main() function), it’s easy to run the process via the shell from Xojo. If it is the latter, you’d have to wrap the function with some code that exposes it as something that can be called from the command line, and then you are good to go. This would be akin to writing a main() in C, getting the command line arguments, and calling the method in question. There are many examples of this that you could copy/paste the code for, and some libraries that can be used, as well. This tutorial shows how to do it and includes some links to libraries, for example: Command-Line Arguments in Java | Baeldung . But, again, it’s not completely stand alone as you would need a JRE on the user’s system.

Java has caused me so many issues over the years that I have an almost unhealthy hate for the language. The need for the JRE can be a serious pain in the backside. Personally I wouldn’t go near Java again.

4 Likes

As I’m currently dealing with a JRE bytecode version issue in deploying someone else’s software, I’d have to agree :+1:

1 Like

How many lines of Java code are we talking about?

Thank you for asking.
About 1000, of which quite a lot are class /struct definitions
One person is looking at this for me at the moment. If they cannot help or are not interested, perhaps I can show you what it says.
The job is take code that reads and populates some Java arrays/lists , and turn it into Xojo code that reads and populates similar structures in Xojo. I can take it from there.

I can report that after a Herculean effort, the process of porting the Java code I had into workable Xojo code has been completed for me by Norm.
I am immensely grateful - seeing what was required was a real eye -opener and Im very impressed.

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.