We have a JAVA applet in two different environtments (preproduction and production environtment), and we want connect the dynaTrace agent from one client machine depending the environtment selected by user.
Now we have the JAVA_OPTS system environtment variable configured to one specific environtment, and we are planning to use scripts to modify the JAVA_OPTS value and start browser, for each environtment, but some one can provide us any other solution more elegant ?
Thanks in advance.
Answer by James D. ·
If I understand this correctly, you have an in-browser java applet that you're going to instrument with the Java agent. However, you need to be able to pass the proper collector name depending on the environment. And, right now, you're just changing the JAVA_OPTS environment variable to go between PRD and Pre-PRD
I am going to assume Windows as the OS; I'm also going to assume an embedded applet and not a WebStart application.
Unfortunately, there is no elegant way other than using a batch file to set these options. This would be true for Windows, OSX, *NIX, etc., also true of WebStart. Using a batch file is not terribly clever but definitely works. Also, setting the environment inside of the batch file does not alter or add the environment variable to the system, just to that specific session of the batch file.
The good news is you don't have to get fancy and write a large or complicated solution to make it all work. For example, the following three liner will do the job.
@ECHO OFF
set JAVA_OPTS="-agentpath:dtagent.dll,server=proddtcollector:9998,name=PRD_WebClient"
"C:\Program Files\Internet Explorer\iexplore.exe" http://prodserver/myapplet
You've no doubt stumbled across this page: Java Agent Configuration; and Google turned up this Oracle doc: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/plugin.html which explains how to do instrument an applet.
Hopefully this helps, or gets you going in the right direction.
JANUARY 15, 3:00 PM GMT / 10:00 AM ET