WebBrowser 中不显示 java小程序 Applet
2013-12-01 15:20
363 查看
网页中有一个 java小程序 (Applet)
用ie 或者 世界之窗 可以正常使用 这个页面 内容完整
使用 WebBrowser 打开以后就 WebBrowser java小程序的位置就会显示为 一个灰色的 矩形【本来是有内容的】
打开页面过程中 会提示错误 *****为空或不是对象
解决方法 增加环境变量JAVA_PLUGIN_WEBCONTROL_ENABLE = TRUE
说明:可以调用API实现
错误提示依然存在 但是能用了
网上也有说JAVA_PLUGIN_WEBCONTROL_ENABLE=1即可解决!
转自:http://blog.163.com/xiaobingking@126/blog/static/322371372011016134892/
C# 实现环境变量(采用 Environment 类)
============ 更改注册表===========================
注意,采用此方式修改的环境变量其实是修改了注册表里的变量值,修改之后,系统环境变量并没有更新,因此需要重启计算机,不推荐使用
/article/7030090.html
转自:/article/2492652.html
用ie 或者 世界之窗 可以正常使用 这个页面 内容完整
使用 WebBrowser 打开以后就 WebBrowser java小程序的位置就会显示为 一个灰色的 矩形【本来是有内容的】
打开页面过程中 会提示错误 *****为空或不是对象
解决方法 增加环境变量JAVA_PLUGIN_WEBCONTROL_ENABLE = TRUE
说明:可以调用API实现
Environment.SetEnvironmentVariable(StrName, strValue, EnvironmentVariableTarget.Machine);
错误提示依然存在 但是能用了
网上也有说JAVA_PLUGIN_WEBCONTROL_ENABLE=1即可解决!
转自:http://blog.163.com/xiaobingking@126/blog/static/322371372011016134892/
C# 实现环境变量(采用 Environment 类)
private void setEnvi(String StrName, String strValue) { Environment.SetEnvironmentVariable(StrName, strValue, EnvironmentVariableTarget.Machine); } private void setPathWithVariable(String strVariable) { String strHome = "%" + strVariable + "%"; setPathAfter(strHome); } private void setPathAfter(String strHome)//此时不会刷新path,需重启后刷新 { String pathList = Environment.GetEnvironmentVariable("PATH"); //检测是否以;结尾 if (pathList.Substring(pathList.Length - 1, 1) != ";") { Environment.SetEnvironmentVariable("PATH", pathList + ";"); pathList += ";"; } string[] list = pathList.Split(';'); bool isPathExist = false; foreach (string item in list) { if (item == strHome) isPathExist = true; } if (!isPathExist) { Environment.SetEnvironmentVariable("PATH", pathList + strHome + ";", EnvironmentVariableTarget.Machine); } }
============ 更改注册表===========================
注意,采用此方式修改的环境变量其实是修改了注册表里的变量值,修改之后,系统环境变量并没有更新,因此需要重启计算机,不推荐使用
/article/7030090.html
class SysEnvironment { /// <summary> /// /// 获取系统环境变量 /// /// </summary> /// /// <param name="name"></param> /// /// <returns></returns> /// public static string GetSysEnvironmentByName(string name) { string result = string.Empty; try { result = OpenSysEnvironment().GetValue(name).ToString(); //读取 } catch (Exception) { return string.Empty; } return result; } /// <summary> /// 打开系统环境变量注册表 /// </summary> /// <returns>RegistryKey</returns> private static RegistryKey OpenSysEnvironment() { RegistryKey regLocalMachine = Registry.LocalMachine; RegistryKey regSYSTEM = regLocalMachine.OpenSubKey("SYSTEM", true); //打开HKEY_LOCAL_MACHINE下的SYSTEM RegistryKey regControlSet001 = regSYSTEM.OpenSubKey("ControlSet001", true); //打开ControlSet001 RegistryKey regControl = regControlSet001.OpenSubKey("Control", true); //打开Control RegistryKey regManager = regControl.OpenSubKey("Session Manager", true); //打开Control RegistryKey regEnvironment = regManager.OpenSubKey("Environment", true); return regEnvironment; } /// <summary> /// /// 设置系统环境变量 /// /// </summary> /// / <param name="name">变量名</param> /// <param name="strValue">值</param> public static void SetSysEnvironment(string name, string strValue) { OpenSysEnvironment().SetValue(name, strValue); } /// <summary> /// /// 检测系统环境变量是否存在 /// /// </summary> /// <param name="name"> /// </param> /// /// <returns></returns> public bool CheckSysEnvironmentExist(string name) { if (!string.IsNullOrEmpty(GetSysEnvironmentByName(name))) return true; else return false; } /// <summary> /// 添加到PATH环境变量(会检测路径是否存在,存在就不重复) /// /// </summary> /// <param name="strPath"></param> public static void SetPathAfter(string strHome) { string pathlist ; pathlist = GetSysEnvironmentByName("PATH"); //检测是否以;结尾 if (pathlist.Substring(pathlist.Length - 1, 1) != ";") { SetSysEnvironment("PATH", pathlist + ";"); pathlist = GetSysEnvironmentByName("PATH"); } string[] list = pathlist.Split(';'); bool isPathExist = false; foreach (string item in list) { if (item == strHome) isPathExist = true; } if (!isPathExist) { SetSysEnvironment("PATH", pathlist +strHome+ ";"); } } public static void SetPathBefore(string strHome) { string pathlist; pathlist = GetSysEnvironmentByName("PATH"); string[] list = pathlist.Split(';'); bool isPathExist = false; foreach (string item in list) { if (item == strHome) isPathExist = true; } if (!isPathExist) { SetSysEnvironment("PATH", strHome + ";" + pathlist); } } public static void SetPath(string strHome) { string pathlist; pathlist = GetSysEnvironmentByName("PATH"); string[] list = pathlist.Split(';'); bool isPathExist = false; foreach (string item in list) { if (item == strHome) isPathExist = true; } if (!isPathExist) { SetSysEnvironment("PATH", pathlist + strHome + ";" ); } }
Kernel32.DLL内有SetEnvironmentVariable函数用于设置系统环境变量 C#调用要用DllImport,代码封装如下: class SetSysEnvironmentVariable { [DllImport("Kernel32.DLL ", SetLastError = true)] public static extern bool SetEnvironmentVariable(string lpName, string lpValue); public static void SetPath(string pathValue) { string pathlist; pathlist = SysEnvironment.GetSysEnvironmentByName("PATH"); string[] list = pathlist.Split(';'); bool isPathExist = false; foreach (string item in list) { if (item == pathValue) isPathExist = true; } if (!isPathExist) { SetEnvironmentVariable("PATH", pathlist + pathValue+";"); } } }
转自:/article/2492652.html
相关文章推荐
- 编写一个显示“欢迎学习Java”的Java Applet程序
- 显示”欢迎学习Java“的Java Applet程序
- 浏览器无法显示嵌入网页代码中的Applet java程序
- 编写一个显示“欢迎学习Java"的Java Applet程序
- Java编写日历程序,显示当前月份及日期
- 利用Java Swing技术设计一个鼠标点击速度比赛游戏程序。程序显示一个按钮和一个文本框,用户点击按钮,文本框显示鼠标点击次数。两个人同时运行本程序,即可进行比赛
- JAVA应用小程序(Applet)
- java applet程序实例 运行
- 简单Java图书管理程序(只实现了界面的显示)
- Java 学习笔记 (7) - GUI编程之Java小程序 Applet
- java项目显示红叉,程序却没有错误
- Eclipse编写和调试Applet程序,调试的时候Eclipse会自动调用Java "小程序查看程序",而不用嵌入到网页中查看运行效果。
- Java Application 和Java Applet程序的主要区别是什么?
- Java编写一个简单的TCP通信程序。服务器发送一条字符串,客户端接收该信息并显示。
- java swing编程时如何让程序窗口居中显示
- java web 程序---jsp连接mysql数据库的实例基础+表格显示
- Java写的GUI程序在Gnome下显示中文乱码,不显示菜单等问题
- Java 之 何以一见钟情 《第一个Java程序和Applet程序》
- java程序中没有错,但是项目上面显示一个红叉的解决办法
- Linux下Java程序中中文显示的一些问题的总结