html实现调用jar包
整体思路:html引用URL protocol-本地注册表key,key对应某一c#写的exe可执行文件,由exe可执行文件调用cmd,cmd执行jar包。
1、添加注册表:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Print]
"URL Protocol"="d:\\Print\\SupplementPrint.exe"
@="PrintProtocol"
[HKEY_CLASSES_ROOT\Print\DefaultIcon]
@="d:\\Print\\SupplementPrint.exe,1"
[HKEY_CLASSES_ROOT\Print\shell]
[HKEY_CLASSES_ROOT\Print\shell\open]
[HKEY_CLASSES_ROOT\Print\shell\open\command]
@="\"d:\\Print\\SupplementPrint.exe\"\"%1\""
说明:第一行,注册版本信息,无需关注;2,、注册表中key值,html中也需要引用这个key“Print”,3、此key对应的exe文件。4、协议名称。。。
2、编写C#调用cmd.exe,cmd再调用jar包。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using System.Text.RegularExpressions; namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//string fullPath = System.Windows.Forms.Application.ExecutablePath;
//System.Console.WriteLine("Hello world");
//System.Console.WriteLine(fullPath);
//string fileName = System.IO.Path.GetFileName(fullPath);
//string folderPath = fullPath.Substring(,fullPath.Length-fileName.Length);
//string cmd = "start " + folderPath + " jre/bin/javaw - jar " + folderPath + "zte-mes-supplementPrint-javaFX-0.0.1-SNAPSHOT.jar";
//System.Console.WriteLine(cmd);
RunCmd(cmd);
} private static void RunCmd(string cmd)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
//string str = Console.ReadLine();
string str = @"java -jar c:\\Users\\10244896\\Desktop\\print\\zte-mes-supplementPrint-javaFX-0.0.1-SNAPSHOT.jar" + "&exit";
str = str.Trim().TrimEnd('&');
p.Start();
p.StandardInput.WriteLine(str); p.StandardInput.AutoFlush = true;
//p.StartInfo.Arguments = "java -jar c:\\Users\\10244896\\Desktop\\print\\zte-mes-supplementPrint-javaFX-0.0.1-SNAPSHOT.jar"; p.WaitForExit();
// throw new NotImplementedException();
}
}
}
说明:仅关注runCmd方法即可。
3、编写html
<a href="Print://hello">Print</a>
html实现调用jar包的更多相关文章
- Unity调用Android的两个方式:其一、调用jar包
unity在Android端开发的时候,免不了要调用Java:Unity可以通过两种方式来调用Android:一是调用jar.二是调用aar. 这篇文章主要讲解怎么从无到有的生成一个jar包,然后un ...
- Loadrunner11.0调用Jar包
又好几天不写东西了,是不是意味着最近没有大的进步,时时敲打自己. 今天把loadrunner如何调用Jar包搞定了,现在把配置的过程中需要注意的东西写下来,分享给小伙伴儿,减少他们在前行路上的弯路. ...
- winform调用jar包
因为工作需要,需要做一个数据上传的程序,客户规定的是:数据接口采用http连接,采用JSON-RPC轻量级远程调用协议.所以决定用winform做一个管理界面(其中还包括其他的功能),java完成数据 ...
- (转载)Python 的 JPype 模块调用 Jar 包
Python 的 JPype 模块调用 Jar 包 背景与需求 最近学习并安装使用了HttpRunner框架去尝试做接口测试,并有后续在公司推广的打算. HttpRunner由Python开发,调用接 ...
- Python调用jar包中的方法
[本文出自天外归云的博客园] 需求 最近在后台项目代码中一段自定义的AES加解密的程序在平时的测试工作中应用频繁.因为写脚本经常会需要使用,而经过各种尝试,比如jpype等,都不尽如人意.最后转换思路 ...
- 如何制作Jar包并在android中调用jar包
android制作jar包: 新建android工程,然后右击,点击导出,选择导出类型为Java下的JAR file,在java file specification 中不要选择androidmani ...
- jmeter 调用jar包 本地加密
1.因为加密接口是有我们自己加密方式,所有加密包由开发提供,获得加密包后方式jmeter目录/lib/ext文件夹中 2.选择引入加密包 3.添加BeanShell Sampler和Debug Sam ...
- python实战===用python调用jar包(原创)
一个困扰我很久的问题,今天终于解决了.用python调用jar包 很简单,但是网上的人就是乱转载.自己试都不试就转载,让我走了很多弯路 背景:python3.6 32位 + jre 32位 + ...
- Unity调用Android的两种方式:其一、调用jar包
unity在Android端开发的时候,免不了要调用Java:Unity可以通过两种方式来调用Android:一是调用jar.二是调用aar. 这篇文章主要讲解怎么从无到有的生成一个jar包,然后un ...
随机推荐
- Django组件-forms
forms组件 校验字段功能 针对一个实例:注册用户 模型:models.py class UserInfo(models.Model): name=models.CharField(max_leng ...
- 【转】mac环境下Android 反编译
一.需要的工具 apktool:反编译APK文件,得到classes.dex文件,同时也能获取到资源文件以及布局文件. dex2jar:将反编译后的classes.dex文件转化为.jar文件. jd ...
- linux中epoll模型
epoll是linux内核为处理大批量文件描述符而作了改进的poll,是linux下IO复用select/poll的增强版本. 一.epoll的主要接口是: 1.创建 (1)int epoll_cre ...
- 帆软报表(finereport)单元格中各颜色标识的含义
帆软报表(finereport)单元格中,可根据单元格角标的颜色判断单元格进行的操作 过滤:单元格左下角黄色三角形 条件属性:单元格左上角红色三角形. 控件:单元格右侧中间的各种矩形. 左父格:单 ...
- Python基础【第二篇】
一.Python的标准数据类型 Python 3中主要有以下6中数据类型: Number(数字).String(字符串).List(列表).Tuple(元组).Sets(集合).Dictionary( ...
- 关于PHP上传文件时配置 php.ini 中的 upload_tmp_dir
在<PHP 5.3 入门经典>9.6.3 的试一试中(P235),给出了一个上传文件的例子,这里的文件格式为jpeg图片(image/jpeg).如果之前未配置 php.ini 中的 up ...
- 27)django-form操作示例(动态Select数据,自定义字段验证,全局验证等)
1)普通传递select数据 # -*- coding:utf-8 -*- __author__ = 'shisanjun' from django import forms from django. ...
- mysql group by 过滤字段 只能在SELECT 后面出现,不能写其他字段 报错解决 关键字 sql_mode=only_full_group_by
1:报错 关键字 sql_mode=only_full_group_bymysql> select uuid,ip,count(*) from dbname_report.t_client_i ...
- c++ ignore用法
转自 http://blog.sina.com.cn/s/blog_4b3336c50102v45n.html std::cin.ignore() can be called three diffe ...
- beta冲刺3/7
目录 摘要 团队部分 个人部分 摘要 队名:小白吃 组长博客:hjj 作业博客:beta冲刺(3/7) 团队部分 后敬甲(组长) 过去两天完成了哪些任务 整理博客 ppt模板 接下来的计划 做好机动. ...