Dose any one can run imagej plugin by using jni? - java

Recently I am using java and maven dependency to run a program. At first, I used a jni file(libtensorflow_jni-1.7.0) during mvn compiling to generate jar plugin for imagej, and it works well. Then I changed jni dependency(libtensorflow_jni_gpu 1.12.0) in my pom.xml. After compiling, I trying to use the generated jar file in imagej, but the plugin failed( it used to work before i use that jni). There is no error message. Is there any way I can fix this?

Related

Or-tools java.lang.NoClassDefFoundError: com/sun/jna/Platform

Hi I'm trying to run this sample code on my eclipse ide and have manually adding the jars file without using the pom file provided but it's complaining with this error.
I managed to compile and run the sample code using 'make run' command.
Any idea is it possible to copy the library jar files and use it in my own project in eclipse?

Minecraft Plugin and JSoup.jar

I'm creating a Java Project in Eclipse, write some parser, which gives a random names with use a JSoup Library and when i started a server it gives me a error java.lang.NoClassDefFoundError: org/jsoup/Jsoup. Eclipse files.
I also use Json-simple and everything is fine with it. JSoup is added as an external JAR library, and the error occurs only when I use Jsoup.connect().get; that is, the imported org object.jsoup.nodes.Document does not cause errors.
P.s. I looked through my plugin using 7-zip and there is JSoup.jar in the libs folder, which means that the plugin is correctly assembled in a vmset with libraries.
You don't have your libraries in the server.
To fix it, you can:
Add them in the compiled jar. To do this, just check compilation options, or convert your project as maven or gradle
Use another plugin that implement them.
Load library jar from your plugin such as explained here or here

Execute jni in Maven ubuntu

I have to call native function from Java with JNI and Maven on Ubuntu 14.04. I have generated .so file and I don't know how to specify in Maven pom.xml file to access .so file. I searched about this and I got the following link: Calling native functions from Java with JNI and Maven
So, as per the link should I create multiple pom.xml files to execute?
Also, I came across posts suggest to use plugin such as NAR plugin to execute JNI with Maven. Please guide me on how to execute JNI with Maven on Ubuntu.

Submitting Spark Application through command line

I have a Spark Application which I initially created using maven. I converted my maven project into an Eclipse project, and I am now working on it via Eclipse.
I also have my own version of the Spark source code to which I have made some modifications and added additional methods. I am able to build my version of Spark and obtain the jar file for spark-core.
In my Eclipse project I now replace the spark-core that is in the build path with the newly built spark-core jar. I am able to utilize the new methods I created and verify this by running the application through Eclipse.
Now, I am trying to submit my application through the command line. I use the spark-submit command from the Spark project I have modified. When I submit my jar, I get an error saying the method I created does not exist. I'm not sure what I'm doing wrong. I would appreciate some insight on what I should be doing.
UPDATE
I now understand that there are certain jars that I need to have from my custom build. Exactly which jars are these? I understand the spark-assembly jar is one. Are there any others?

Packaging and deploying a Jython program from Eclipse

So I've been pigeon-holed into writing some Jython code. I've been using the latest version of Eclipse IDE with the PyDev plugin for development. Up until now, things have been moderately tolerable. I've gotten all my Python scripts working and I'm successfully including a couple of JAR files and the class directory of another Java project as external dependencies. Everything seems to run fine through the Eclipse IDE.
Now I need to package everything up and deploy it. From what I can gather, the best way to do this would be to package everything up in a JAR file. The Jython documentation suggests starting out with the jython.jar file and adding to it. OK. So I modify my main python module and start adding all my python source to the JAR.
It executes but of course can't find all the external dependencies.
How is one supposed to add the external JAR files so that they are correctly seen by the Jython interpreter? How is one supposed to manage more complex dependencies in a setup like this?
Is there a plugin for Eclipse or maybe something like Ant or Maven that can handle all of these steps for me with the push of a button?
I can't be the first person that has needed to deploy Jython code with complex dependencies can I?
I've made some headway on getting this all working so I thought I would put some notes here in case they help anyone else out. I'd still like to hear from others on their experiences trying to put together something like this.
It turns out that Eclipse as of 3.5 has a project export option for Java -> Runnable JAR File. If you use this option, you can point to a Java main class in the export wizard. You also have the option to have it repackage all the JARs that you are dependent on in your new JAR file. Make sure to check the box to save the export as an ANT build so that you can repeat the process quickly. NOTE that the first time you do this through the interface, it may fail, but it will still have created a JAR file.
Now here's where it gets strange. To track all the dependencies, I am still using a mostly incomplete Maven build in my project. I create the Maven .POM file. And I told Maven what my external JAR dependency was. I then told Maven to do a dependency update for me. It pulled everything into my Maven repository as expected.
Now when I do my ANT build, it appears that it is getting its list of JARs to include in the final build from Maven. I'm not really sure if it is supposed to work that way. I'm also not 100% sure that it is working. I guess I'll find out when I have to add another external JAR to the project.
Anyways, if you follow this question you'll see that you can take the latest builds of Jython and pull the org.python.util.JarRunner.java file out and use it in your own project. This is you Java.main class that you will need to point your ANT build at. From there, convert your main Python/Jython script to be the run script that was talked about in that question.
Next, build up another copy of the Jython JAR file in your Jython directory. This one should have the /Lib directory pulled into the JAR. Save that off and then point your Eclipse IDE Jave Build option for your PyDev project at that JAR as an external dependency. Your JarRunner will now work and execute the run.py file under Jython.
If all that works, you should then be able to rerun the ANT exported build from earlier and you will end up with a single JAR file that you can execute on the command line as:
java -jar {yourjar} args
And distribute to your customers without any additional dependencies.
If that all seems a little bit convoluted, it is. If anyone has a better way of setting this all up using Eclipse, please let me know.
Make your life easier and just use Maven and the mavenjython compile plugin.
See my answer of this question: Using Jython with Maven
You get full automation of the build and deploy process, and the result is a jar that includes jython and all other dependencies.

Categories