设置要用于小程序启动的默认JVM参数 [英] Set default JVM parameters to be used for applet launch

查看:719
本文介绍了设置要用于小程序启动的默认JVM参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试远程调试Java小程序,但我似乎无法获取-agentlib:jdwp JVM参数。我已经尝试在Java控制面板中为特定的JRE指定它,我已经尝试通过用于启动小程序的JNLP文件进行设置。



为applet启动设置JVM参数的正确方法是什么?特别是远程调试。

解决方案

查看类似的SO问题,我发现以下答案...



有时要调试一些安全性相关的东西浏览器插件环境与appletviewer不同。以下是您可以在浏览器中有效调试小程序的方法:



1)获取二进制文件的调试信息



从JRE_HOME / lib备份.jar文件



(下载和)安装与JRE相同版本的JDK。 >

将JDK_HOME / jre / lib中的.jar文件复制到JRE_HOME / lib



JDK中的文件已编译为包含的调试信息(源代码行号信息,变量名等)和JRE文件没有这个信息。



没有这个,你不会可以有意义地进入调试器的核心类代码。



2)为Java插件启用调试



转到Java控制面板/ Java / Java运行时设置/查看/用户/运行时参数



并添加选项以启用调试。这样的东西:

  -Djava.compiler = NONE -Xnoagent -Xdebug -Xrunjdwp:transport = dt_socket,address = 2502,server = y,suspend = n 

有趣的选项是端口(在这里使用2502,你可以使用漂亮很多任何空闲端口,只是写下来稍后)和挂起 - 如果你需要调试applet启动,类加载等,将其设置为y。这样,当您访问applet页面时,浏览器将显示为冻结,因为JVM会立即挂起等待调试器连接。



3)使用您的喜欢的IDE远程调试Java插件



在Eclipse中,例如,选择运行/调试配置... /远程Java应用程序



点击新建按钮。



确保连接类型为Socket Attach,选择localhost作为主机如果您的浏览器是本地的,以及您之前选择的端口(示例中为2502)。



您可能必须在源选项卡上阻止JDK中的src.zip使用Java核心类源可用。



保存配置,一旦您的浏览器运行插件(JVM已暂停或不挂起)就运行远程调试器连接到插件JVM,包含您的Applet源的项目打开。


I am trying to remote debug a Java applet, but I cannot seem to get the -agentlib:jdwp JVM argument to work. I have tried specifying it in the Java control panel for the particular JRE used, and I have tried setting it via the JNLP file used to launch the applet.

What is the correct way to set JVM parameters for applet launch? In particular, to debug remotely.

解决方案

Looking at a similar SO question, I found the following answer...

Sometimes to debug some security related stuff the browser plugin environment is just too different from appletviewer. Here's what you can do to effectively debug applets in the browser:

1) Obtain debugging info for the binaries

Backup the .jar files from JRE_HOME/lib

(Download and) Install a JDK for the same version as your JRE.

Copy the .jar files from JDK_HOME/jre/lib to JRE_HOME/lib

The files inside the JDK were compiled with the debugging information included (source-code line number information, variable names, etc) and the JRE files don't have this information.

Without this you won't be able to meaningfully step into core class code in your debugger.

2) Enable debugging for the Java Plug-in

Go to the Java Control Panel / Java / Java Runtime Settings / View / User / Runtime Parameters

And add the options to enable debugging. Something like this:

-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=2502,server=y,suspend=n

The interesting options are the port (using 2502 here, you can use pretty much any free port, just write it down for later) and the suspend - if you need to debug the applet startup, classloading, etc, set this to "y". That way when you access an applet page, the browser will appear to freeze as the JVM immediately gets suspended waiting for a debugger to connect.

3) Use your favorite IDE to Remotely debug the Java Plug-in

In Eclipse, for instance, choose Run / Debug Configurations ... / Remote Java Application

Click on the "New" button.

Make sure connection type is "Socket Attach", choose localhost as the host if your browser is local, and the port you chose earlier (2502 in the example).

You might have to inlude the src.zip in your JDK on the sources tab to have the Java core class sources available.

Save the configuration, and once your browser is running the plug-in (with the JVM suspended or not) run the remote debugger to connect to the plug-in JVM, with a project containing your applet sources open.

这篇关于设置要用于小程序启动的默认JVM参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆