Is there a way to identify the JVM's default time zone without running a Java program on it? Are there any commands available using which I can take a look at it?
Yeah we all know what jvm is , but maybe author want to know what is a default timzeone of running jvm without restarting it and deploying code on it.
In such case you could maybe check command line of java process for properties (user.timezone) or connect to jvm via some tool like visual vm and check this property, I am not sure if there is some other way to do that.
If you have remote debugging enabled then it should be easier as you can connect via your favourite ide/tool and just evaluate default timezone.
Related
I have a java app which runs on a linux/unix machine.
When setting the system time via system command, on the console using date I see that the date/time has changed, but it seems as my JVM didn't recognize this change.
It seems that this is not a rights problem, because in the shell I see that the date/time has changed. Only my JVM didn't recognize this change.
Any hints where to search ?
Take a look at this post over on the super user stack exchange. There are 2 different clocks in linux. One is hardware (hwclock) and the other is os/system.
I have searched many places of making IPv6 enabled to have a dual-stack machine IPv6.
I found many have answered to set java.net.preferIPv6Addresses=true which is set to false by default.
I want to know where exactly should I make these changes, i.e in which file or do I have to write some Java code to put this into.
The setting needs to get into the JVM's system properties ... and it needs to be there before the relevant part of the Java class library initializes.
The "bomb proof" way to do this is to pass the setting to the JVM as a command line parameter; e.g.
java -Djava.net.preferIPv6Addresses=true ... com.example.MainClass <args>
You could also code your application to inject the setting using
System.setProperty("java.net.preferIPv6Addresses", "true");
but you need to ensure that the injection happens soon enough1, and that would not be trivial.
1 - "Soon enough" means before JVM networking code's static initialization has occurred. This can be difficult to achieve in a complex application. Note the the Network Properties documentation states: "Some are checked only once at startup of the VM, and therefore are best set using the -D option of the java command ...". Note that it does NOT state that those properties can only be set that way.
The suggestion of using a JAVA_OPTS environment variable will only work for some applications. The handling of JAVA_OPTS will happen in your application's launcher or wrapper script before the JVM is launched. The same applies to _JAVA_OPTIONS ... which is one that I've not seen before.
(If the application you are using is properly documented, then its documentation should explain how to specify options that need to be passed to the java.exe launcher.)
The standard java.exe and javaw.exe commands certainly DO NOT pay any attention to the JAVA_OPTS environment variable.
you must put in in your enviorment path before running the java executable.
in linux
export JAVA_OPTS="-Djava.net.preferIPv4Stack=true" (same for ipv6 )
Hi I need to see eclipse's running configuration in a simple java project. for example print them as key value pairs at console would be enough
[EDIT]: the reason for this
I added a parameter to eclipse.ini but I'm not sure about the value whether it is passed as I expect or not
and the parameter I'm looking for is
-Dorg.eclipse.swt.browser.XULRunnerPath=xulrunner
You have two ways for getting the details
http://www.mkyong.com/java/how-to-list-all-system-properties-key-and-value-in-java/
In case it is java parameters
Read Java JVM startup parameters (eg -Xmx)
From your updated response.
I will suggest that you check your memory manager.
In windows that will be task manager
mac that will be Activity Monitor
on linux you can fire top command from command line
Still not satisfied, check over this StackOverflow thread
Monitoring own memory usage by Java application
Still not satisfied. I would suggest profiling of the application using yourkit profiler or any other java profiler.
When you start yourkit it shows the java applications running. Simply click on one of it and it will initate profiling for you.
Eclipse runs on a JVM, which is not the same JVM where your program will run.
It would be easier to find the configuration file (eclipse.ini I guess is what you are looking for), since they will not be environment settings for the JVM where your code will run.
all runtime configuration endsup being a java argument or a system property passed
so you can print all the commandline argument passed in to java + all the System properties and its values (may be with filtered set of key value based on your interest)
I want to modify the default jvm setting, like gc policy and Xmx.
Because of some reason, I can't modify the starting command of java program to add these setting.
Is there any ways to do that?
Thanks.
[updated]
Sorry I didn't describe it clearly.
It is something like server side job program which is started from another server program. Because of the default Xmx is too big(on 64 bit server), minor GC time is too long, almost 1 second. So I want to change the default GC policy to test.
And for now, the server program can't be modified.
You can have the Java program relaunch itself. You can have a bootstrap main which is called first. It then does a Runtime.exec(...) with the command line option you require running a different Class.main() which is the actual program.
Short answer: with your requirements you can't do this.
Theoretically you have 2 possibilities:
Provide settings via comand line options:
I can't modify the starting command of java program to add these setting
Change settings at run time:
But it's impossible
I was watching the livestream at http://www.humblebundle.com, and I saw them running the application, AND making changes to the code in Eclipse. Is this just changes for the next time they compile and run, or was he actually changing the application as it was running somehow?
Sometimes.
In Debug mode, eclipse can compile and change class files in a running JVM, this is called Hot Code Replace.
The idea is that you can start a debugging session on a given runtime
workbench and change a Java file in your development workbench, and
the debugger will replace the code in the receiving VM while it is
running. No restart is required, hence the reference to "hot".
Source: Eclipse Wiki
There are certain circumstances where this won't work, in which case Eclipse will prompt you to restart.
This is called hot code replace:
The idea is that you can start a debugging session on a given runtime workbench and change a Java file in your development workbench, and the debugger will replace the code in the receiving VM while it is running. No restart is required, hence the reference to "hot".
It's not really possible to tell from the stream. Java's capable of both to some extent - you can, with some restrictions, replace classes loaded by a JVM using the debugger. There's also JRebel, which gets rid of a great deal of those restrictions.
Ability to change application code while running is the feature of debugger. In Eclipse and many other popular IDEs it works "out of the box". Feature has several restrictions: can't change method signatures, add/remove class members, etc.
If you are in debug mode you can make certain changes while the application is running. Whether or not it is valid varies based on if the change is to currently loaded code. For example, you could change a sort function while the program isn't sorting and it will use the new code the next time it sorts.