Eclipse: quick run/preview vs. run main - java

I am wondering why they 'quick run/preview' displays object different that when you select 'main run' in Eclipse. I personally find that objects look better/neater/more elegant in quick run/preview mode than when I when I run and compile the application via the 'main run' option.
Can anyone tell me there is such a big difference, and what I need to do to actually make my application and its objects look like in 'quick run/preview' mode?

Quick run/preview in Eclipse is used to compile the code and run it more efficiently than normal run. I'm assuming you are referring to this when you are building GUI's?
Anyhow, quick run/preview is just to quickly preview your application regardless of the looks.
I'm assuming you want your GUI to have the Look and Feel of a Windows application rather than the "metal" Java GUI look.
This is done relatively easy as you can both make the "Look and Feel" of your application be based on whatever OS you are running or which one you prefer.
Refer to this simple article here.

Related

Performance measuring

I wanted to know if there is a way to measure the overhead of a specific function or even the running time of an application in Eclipse (with the capability to run the test for arbitrary times to get the average time).
I have a code that should be executed in Eclipse therefore looking for such a thing. I know that we have Jmeter in Netbeans and I'm looking for something similar in Eclipse.
Thanks
I have had good experiences with JProfiler. It should be precise enough to give usable data even when you run your function only once, depending on how you set it up. It also optionally integrates with Eclipse.
It's not free, but there's a fully functioning trial available.
I used Traceview before and it worked quite good to me.
It quite easy to use, just open the DDMS view in eclipse and look for the icon with three arrows with a red dot (Start Method Profiling). Click the icon and test your app as you want. When you are done click on stop. The trace should open in a new tab.
You could use the following
http://www.jvmmonitor.org/
It's called Java Monitor and comes as an eclipse plugin. You can install it from eclipse market place.

create own plugins or add on for netbeans

is it possible to create a plugin or add on for netbeans such that whenever i run or compile a project, a pop up box shows me that run complete or build complete. I know i can create a pop up box using java. this is just to know, consider something like learning process.
I assume that you can do something like so, please take a look at this Netbeans Plugin Tutorial.
However, what you are requesting, a build complete notification is already available through Netbean's Console output window. Also, popups can get pretty annoying pretty fast, so be careful.

Is there a program that can tell you which class/method is being invoked

I'm working on a very big java/servlets/web project and i find it hard finding which classes and and methods is being called. sometimes it takes hours to find the right class. if there an application or plugin or technique that helps a little? im using eclipse.
edit: I'm using apache and tomcat
Regarding your comment to Bozhos answer: use a profiler on your server instance. You start profiling right before you click on a link in your client application ("the browser") and stop right after you have the correct response. Then just examine the profiler logs/views to find out, what actually happend on the server.
The Eclipse Test & Performance Tools Platform Project is worth a try.
CTRL + ALT + H, or right-click > open call hierarchy (when on a method declaration) will give you all callers, with their callers, and so on. You can also reverse the hierarchy
Right click > references > project will give you where a given class is used.
From your comment on Bhozo's answer I conclude that you do NOT mean at development time, but at runtime.
I suggest you connect a debugger to your application and pause it. You can then inspect the callstack at that time, which will usually give you an idea where to look.
To do that, run your java app with the following settings:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Then in eclipse, add a debug configuration for 'remote' to port 8787 and execute it. Your debugger is now linked to your application. Put eclipse into the debug perspective.
Now click a link in your application, and immediately click the pause button in the debugger. You can now see the callstack. Usually, once you have a clue, you can quickly find good spots to put breakpoints. But this technique helps you get a clue :)
You might want to consider the use of AOP to add a tracing/logging aspect to certain parts of your code. This way you don't have to update your code and can simply write an aspect that logs a line for every method that is called with in example the name of the method, the class and the parameters. This aspect can of course be 'turned off' when building your production version to prevent the trace logging on production machines. If you're familiar with AOP, you can easily tweak the aspect and the pointcuts a bit to for instance only log calls to certain methods in your controller classes or something like that.
If you need more information on this solution, feel free to comment on this answer requesting more specific information or simply google for AOP and logging.

To find an execution line-counter for Java IDE

Is there any plugin to some IDE that show the number of times a line is run in the code?
Eclipse's ECLemma does not seem to have a setting to show execution times at the left-hand-side bar, like in the service WebCat.
I think the eclipse test and performance tools plateform would be able to help you with this. It includes a profiler which will instrument your code and provide the information you want.
Careful with profiling, it can be a heavy performance hit depending on how many functions/classes you monitor
Have a look at the breakpoint properties in eclipse may be you can configure a variable to capture the hitcount
What's wrong with writing to a log file or to screen or using a counter?
The focus of code coverage is only if a line is executed or not. Nothing more.
To get counters you would have to look at profiler software and not code coverage.
There are plugins for both Eclipse and Netbeans. I am not sure if they show counters per line, but I think that they show counters per method, which might be what you want...
(source: free.fr)
In NetBeans 6.8 there is a nice code coverage tool which does pretty much that what you want but actually only for ruby. (right click project -> code coverage)
But could you use an ant task or maven plugin? Then Take a look at this list

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