How to get the running time of Java plugins using Eclipse - java

Now I am using a plugin based Java to put into a third party software (ImageJ) to process images. After inputting images, it shows the GUI where I can choose the segmentation parameters and tracking parameters. But it runs slowly after setting parameters on the GUI. Hence, I want to know which part(Segmentation or Tracking) makes the Java code run slowly.If I use Eclipse, can I get the running time of each part and how I can get it because it's a plugin and the running time will be different if I change the parameters on the GUI and input images. Thank you so much.

Related

How to load existing Java code and run it within the program

I’m creating a mock OS in Processing 3, and I want my OS to be able to download and run apps which have been written by a third party.
Basically, I want my OS to be able to load an application file from the user’s computer, get the Java code from the file and run that code within a window object I have created within the OS. Is there any way I can load Java code and run it within the program currently running?
I have hard coded a Settings, Calender and Notes app into my OS, but ideally they would also be kept in files of their own and loaded during the bootup sequence, as would any other applications the user has chosen to install on the OS.

Netbeans problems with reflection

Why Netbeans takes so much time in java.lang.Class.getDeclaredField(String)?
I have isolated my problem and I have two projects:
I created a Netbeans Platform program with one module that has one window and one button in it. So when I click it, program runs the function that I need.
I created a form that will call that function.
So now I have two programs that are the same and run from an AWT thread. The key difference is that one runs under Netbeans Platform structure and the other one is alone.
Profiling the two programs I found that the big problem is when it calls "java.lang.Class.getDeclaredField(String)" Netbeans program takes 30,784 ms and Swing program takes 2,055 ms
It seems to me that Netbeans has some sort of security that checks when somebody is trying to access a class through reflection.
Does anybody knows what is it? and how to turn it off??
Thanks
HS

Is there an easy(read:lazy) way to push code to other machines in java?

I'm pretty green when it comes to java and am playing around with hadoop but I'm finding I am spending so much time pushing code between systems and was wondering if there was an easier way(in python, it was easier because I could just copy/paste the code into the remote systems VI editor with Java, I can't seem to pack all my code into a single large file and thus have to copy/paste many different files).
I do not want to install hadoop locally so I setup an ec2 instance with it but as I write code in eclipse I find myself having to export to a jar, then ftping it, then waiting to run it. I notice a few bugs and repeat this process several times as I make tweaks. I switched to using git(push code from my workstation then pull it on remote system) but I often have to write some message related to the change which is annoying. I am about to write a script to do this but I wanted to ask before I reinvent the wheel. Is there a way within eclipse or something else I can do to make it as easy as when I hit the 'run' button and it saves/compiles/runs my code?
Write an ant script that does the required steps; you can then execute it via the 'Run External Command' menu item / icon.

Using a Java program I made on a Web Server

I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.

Fake X11 display?

I have a Java program using AWT which I would like to run on a headless system. The display for the program does nothing other than display stats. When the program finishes, it exits. There is no user interaction on the display. The program creates an output file which I use in my build system.
Is there a way to get the Java program to run without an X11 display configured? Can I force Java to run the program without trying to display anything? I do not have access to the source code (it is just .jar file), so I can't make modifications to the source.
Any thoughts on how I could get this to work?
The underlying question here is how to run Java applications without an X server; providing a "fake" X server is only one option. In Java 1.4 and up, you can do the following:
java -Djava.awt.headless=true
This allows applications which use AWT to run on headless systems even without an X server.
Xvfb can do what you ask for. I've not used it myself, but here is a link to wikipedia: http://en.wikipedia.org/wiki/Xvfb
You can use a vncserver.
vncserver :1001
export DISPLAY=localhost:1001
java..
The added advantages is that you can actually view the gui
using vncserver 'just in case'
Could also run Xvnc in a low resolution and color depth.
As mentioned by Charles Duffy the traditional method is to tell Java to go headless.
Note that you can always mount the jar in Eclipse and use jad+jadclipse to see what it actually does, and perhaps even override a class if you need to by putting another class-file in "front" of it in the classpath.
A facility that might be relevant if the program uses Java2D is that newer Java versions use optimizations in the X11 server to render faster. This alone might be a reason to devote an X11 server attached to a high performance graphics card to your graphics processing.
I've used with great success in the past the PJA libraries, they don't seem to be maintained anymore, but then again, just just want to run...
I was able to get headless mode in OpenJFX with the command line arguments
-Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw

Categories