How to attach a Java application to jvm profiler in eclipse? - java

I want to memory-profile my Java application with jvm monitor. All docs seem to assume that your application runs on a server. For example, the first picture on http://www.jvmmonitor.org/doc/ shows an application running on "localhost". But I just run my application in eclipse with "Run as -> java application", so my application doesn't appear in the list of servers.

From the FAQ, linked from the docs in your question: Why can I not find any jvms on jvm explorer?
JVMs started in eclipse are running on your localhost, by definition. It's not that they are running in an app server, necessarily.

Related

Should I use headless mode in Spring-boot based backend?

I'm working on a application based on a simple monolithic architecture :rest API backend with spring-boot + frontend with a Js framework.
I have been reading about the headless mode when running java apps and I would like to know if running the embedded tomcat with my spring-boot application in headless mode is a good idea.
Generally you don't need to specify -Djava.awt.headless=true because since around Java 1.8 the JRE determines itself whether a graphics environment is available or not and switches into headless mode if no graphics environment is available.
Relevant source in Java 11: https://github.com/openjdk/jdk11/blob/master/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java#L166
if you are running a Unix-like operating system and the DISPLAY environment variable is not set the headless is true
on Windows it is assumed that a graphics device is always present and therefore headless is false
In general, running an application in a console requires some sort of terminal to write to.
In Unix-based systems, these terminals are referred to as tty.
This implies the following:
Whenever you open a connection to your server via SSH, you get a tty. Your non-headless application will run in that tty until the tty is closed. To avoid that, you'd need something like screen.
For Windows systems: If you close the cmd window of the console/sign off the user, the application server will also stop running.
That's why productive installations are usually headless and service based.
So much for the background, the official docs actually state the following:
In addition to running Spring Boot applications by using java -jar, it
is also possible to make fully executable applications for Unix
systems. A fully executable jar can be executed like any other
executable binary or it can be registered with init.d or systemd. This
helps when installing and managing Spring Boot applications in common
production environments.
This is described here.

How to debug Java applets running in Internet Explorer

I need to debug a Java applet. For now, just getting a heap dump would be a big help, although running something like JavaSnoop would be even better.
The complication is that the applet is part of a complex website that only works in Internet Explorer. While it's theoretically possible to isolate the applet and run it independently, initial attempts to do this have failed.
I have attempted these instructions. However, the debug settings are not taking effect for the Java VM that is running the applet. Port 2502 is not listening. I have tried basic tweaks such as rebooting and running IE as administrator, which have not helped. I've also confirmed that the same command line allows me to debug a standalone Java application.
I'm running JDK 8 and IE 11 on Windows 7.
I'm wondering if IE interfaces with Java slightly differently, so it doesn't obey the Runtime Parameters I have specified in the Java Control Panel.

JavaFX 2 and Linux

JavaFX 2 is not support Linux yet. Does this mean a client Linux machine (user machine) cannot run it or a server Linux machine (host machine) cannot run it or both?
*EDIT:*
JavaFX is for rich client. So the server will not run it, but store it and client will get it and run it, right?
JavaFx depends on hardware acceleration to run. This is currently not supported on linux (expected 2012). So if your server is executing JavaFx code, then it would not run on the server. If it is only delivering code to clients, like in an applet, then it would work.
It means you can't use the JavaFX libraries on a machine running Linux. Neither a client Linux machine, nor a server Linux machine can use them.
Response to Edit
You can still store and serve JavaFX code on Linux machines. You just can't execute the JavaFX code on a Linux machine.
Note that JavaFX is different from Java. You can still use Java on Linux machines.
I realize this question was posed a while back (11/2011), but I thought it might help to point out the related Open Source project from the OpenJDK community called OpenJFX. Feel free to help out with development, if you're qualified to do so as well. Given the secure nature of Linux, this project should prove a secure/safe way to utilize the "hardware acceleration to run"; though, it's still in the development stages.
Take a look at the project wiki to learn how to build OpenJFX on Linux.

Java desktop application take long time to run

When I run any project java desktop application in netbeans (F6) or run any .jar file java desktop application, it's always delay about 20 seconds or more.
I tested this project on another computer, it works ok (no delay).
Does my computer have an error with Java? Any solution for this problem?
Edit 12/11/2011
Is it true? I check my system, and I think my java application load too much because I can't turn on "Java Quick Starter". It is in Control Panel > Java > [tab] Advanced > Miscellaneous > Java Quick Starter
In my laptop, I can't enable Java Quick Starter.
Thanks for your help!!!
Netbeans will compile your project first, this takes a while. A directly ran java application with a reasonable size jar file should not take more than a second to launch. Of course this does not account for the system you use, if everything you do is slow, so is launching java applications.
Maybe you could try to rise the JVM memory and see what happens...
I think there are 2 params you can give to the Javac to do that they are Xmx( max ) Xms(starting mem)
Or you could try to run jviVisualVM which is a app that comes with java for memory throubleshooting it should be inside java\bin directory
In response to your question about Java Quick Starter. The introduction on the sun website show the following:
JQS is enabled by default in Windows XP and Windows 2000 operating systems and is not necessary on Windows Vista as Vista offers its own pre-loading mechanisms.
and later:
Note: JQS service will perform runtime checks and stop running when a laptop is running on batteries. JQS service will resume when the power cord is plugged in, as performance benefit of JQS is largely dependent on overall system configuration.
Perhaps this is one of your problems.

jvisualvm Does not list Jboss 5.1.0GA when running as service

jvisualvm does not monitor the jboss when I run it as service? what changes i need to make so that jvisualvm start monitoring the java application (specifically jboss) when running as window service.
Moreover, When I run the jboss through command prompt (run.bat) jvisualvm start monitoring it.
Please suggest..
VisualVM can automatically detect only java applications running under the same user as VisualVM. See this blog post to find out how you can monitor java process running as Windows service.
Visual VM looks at active JVMs. You need to give it the PID of the JVM that's running your JBOSS instance.
Make sure that you have Visual VM 1.3.2 with all the plug-ins installed. It's a substantial upgrade from the version that ships with the JVM.

Categories