[英]When JAVA_TOOL_OPTIONS will pick?
我正在使用 java 應用程序,其中使用小程序進行某些操作。我想運行一個程序,每次打開任何小程序時。我使用 JAVA_TOOL_OPTIONS 設置打開任何小程序時應調用的類。但是第一次打開小程序時,它正在調用那個類,在任何其他小程序的病房之后,它沒有調用。有人可以幫助解決這個問題嗎?JAVA_TOOL_OPTIONS 是如何工作的?
您可以將 JAVA_TOOL_OPTIONS 設置為操作系統的環境變量。 在 Windows 7 上,您可以轉到計算機 -> 屬性 -> 高級系統設置 -> 高級 -> 環境變量 -> 系統變量 -> 新建以設置 JAVA_TOOL_OPTIONS 的值。
我建議您按如下方式更改項目的設計,以便最好地使用 Applet。 創建一個像“ApplicationBaseApplet”這樣的自己名字的Applet,並使用Applet的生命周期方法修改其中的生命周期。 根據您的要求,您可以在此超類 Applet 的init()
方法中保留要調用的任何代碼。 現在,無論何時創建新的 Applet,都要擴展這個 Applet。 下面的示例代碼。
import java.applet.Applet; // Importing Applet package
import java.awt.Graphics; // Importing Graphics package For GUI
class ApplicationBaseApplet extends Applet
{
// This method loads the applet and is only called only called once in the applet life cycle
public void init()
{
//call the code.....
}
//Applet execution starts from this method.
public void start() {
}
// This method stops or pauses the execution
public void stop() {
}
// This method is executed only once in the life cycle and terminates applet execution
public void destroy() {
}
// This method is used to paint the design of the applet
public void paint(Graphics g)
{
}
}
現在,將此 Applet 用於所有子類型。
import java.applet.Applet;
import java.awt.Graphics;
class FirstApplet extends ApplicationBaseApplet
{
}
import java.applet.Applet;
import java.awt.Graphics;
class SecondApplet extends ApplicationBaseApplet
{
}
import java.applet.Applet;
import java.awt.Graphics;
class ThirdApplet extends ApplicationBaseApplet
{
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.