各位高人,谁知道怎样将Java代码编译成本地的二进制代码

Norwaywoods 2003-01-27 02:00:51
给出这种技术的名字,或者网页都可以。谢谢!
...全文
148 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Norwaywoods 2003-02-17
  • 打赏
  • 举报
回复
function parseType(oS, oschm, o, ssffx)
{
if (o == null)
return null;
switch(o.baseName)
{
case "complexType" :
return parseComplexType(oS, oschm, o, ssffx);
case "simpleType" :
return parseSimpleType(oS, oschm, o, ssffx);
}
return null;
}

function parseArrayType(at, sz)
{
var asa = sz.split("[");
if (asa.length <= 1)
{
asa = sz.split(",");
for (var i = 0; i < asa.length; i++)
{
var ii = parseInt(asa[i]);
at[at.length] = isNaN(ii) ? null : ii;
}
return;
}
for (var i=0; i < asa.length; i++)
parseArrayType(at, asa[i]);
}

function parseComplexType(oS, oschm, o, ssffx)
{
var ns = getQualifier(o.tagName);
if (!o.hasChildNodes())
return null;
var ot = null;
for (var j = 0; j < o.childNodes.length; j++)
{
var o1 = o.childNodes[j];
switch(o1.baseName)
{
case 'sequence' :
case 'all' :
var ao = o1.selectNodes(ns.length ? (ns+':any') : 'any');
if (ao.length != 0)
continue;
ao = o1.selectNodes(ns.length ? (ns+':element') : 'element');
if (ao.length == 0)
continue;
if (ot == null)
ot = new Array();
for (var i = 0; i < ao.length; i++)
{
var s = getAttrib(ao[i], "name");
if (s == null)
{
var s = getAttrib(ao[i], "ref");
if (s != null)
{
oS.refs[s] = ot;
}
}
else
ot[s] = parseElem(oS, oschm, ao[i], ssffx);
}
continue;
case 'complexContent' :
var o2 = o1.firstChild;
switch(o2.baseName)
{
case 'extension' :
var base = getAttrib(o2, "base");
if (base == null)
continue;
var ab = base.split(":");
var oBase = new Object();
oBase.nsuri = ab.length > 1 ? oS.ns[ab[0]] : oschm.uri;
oBase.base = ab.length > 1 ? ab[1] : ab[0];
ot = parseComplexType(oS, oschm, o2, ssffx);
oBase.type = getAttrib(o, "name");
oBase.derivedType = ot;
oBase.fExpanded = false;
if (oBase.type != null)
oS.exts[oBase.type] = oBase;
else
oS.exts[oS.exts.length] = oBase;
continue;
case 'restriction' :
return parseComplexType(oS, oschm, o2, ssffx);
case 'all' :
return parseComplexType(oS, oschm, o1, ssffx);
}
continue;
case 'attribute' :
var soapns = oS.ns[oS.qlt["soap"]];
var wsdlns = oS.ns[oS.qlt["wsdl"]];
var at=o1.attributes.getQualifiedItem("arrayType", wsdlns);
if (at == null)
at=o1.attributes.getQualifiedItem("arrayType", soapns);
if (at == null)
{
if (ot == null)
{
ot = new Array();
ot[getAttrib(o1, "name")] = parseAttrib(o1);
}
continue;
}
var tn = getBaseName(at.value);
if (ot != null)
{
var oe = get1stAryItem(ot);
oe.fArray = true;
oe.sizeArray = new Array();
parseArrayType(oe.sizeArray,
tn.substring(tn.indexOf("[")+1, tn.length));
continue;
}
var oe = new Object();
var a = tn.split("[");
if (a.length < 2)
continue;
oe.ns = getQualifier(at.value);
oe.ns = getUniqueNsq(oS, o1, oe.ns);
oe.name = a[0];
oe.fArray = true;
oe.type = a[0];
if (oe.type == "anyType" && oS.ns[oe.ns] == oS.ns["xsd"])
oe.type = "string";
oe.sizeArray = new Array();
parseArrayType(oe.sizeArray,
tn.substring(tn.indexOf("[")+1, tn.length));
ot = new Array();
ot[a[0]] = oe;
continue;
}
}
return ot;
}

function parseAttrib(o)
{
var attrib = new Object();
attrib.fAttrib = true;
var st = getAttrib(o, "type");
if (st != null)
{
var a = st.split(":");
attrib.type = a.length > 1 ? a[1] : a[0];
attrib.ns = a.length > 1 ? a[0] : null;
}
attrib.fixed = getAttrib(o, "fixed");
attrib.name = getAttrib(o, "name");
attrib.allowed = getAttrib(o, "use") != "prohibited";
return attrib;
}
function parseElem(oS, oschm, o, ssffx)
{
var oe = new Object();
oe.name = getAttrib(o, "name");
var st = getAttrib(o, "type");
if (st == null)
st = getAttrib(o, "xsi:type");
var minOccurs = getAttrib(o, "minOccurs");
var maxOccurs = getAttrib(o, "maxOccurs");
oe.fArray = (maxOccurs != null && maxOccurs != "1");
if (st != null)
{
oe.type = getBaseName(st);
oe.ns = getQualifier(st);
if (oe.ns == '')
oe.ns = oschm.qdef;
if (oe.type == "anyType" && oS.ns[oe.ns] == oS.ns["xsd"])
oe.type = "string";
return oe;
}
oe.ns = oS.nsalias[oschm.uri];
if (typeof ssffx != 'undefined')
oe.type = ssffx + '_' + oe.name;
else
oe.type = oe.name;
var ct = parseType(oS, oschm, o.firstChild, ssffx);
oschm.types[oe.type] = ct;
return oe;
}
function parseSoapHeader(oS, o)
{
var hdrInfo = new Object();
hdrInfo.ns = getAttrib(o, "namespace");
hdrInfo.es = getAttrib(o, "encodingStyle");
var sUs = getAttrib(o, "use");
hdrInfo.fLiteral = (sUs != null && sUs.toLowerCase()=='literal');
var smsg = getAttrib(o, "message");
var amh = oS.msgs[getBaseName(smsg)];
var spart = getAttrib(o, "part");
hdrInfo.fRequired = getAttrib(o, "required") == "true";
hdrInfo.type = amh.args[getBaseName(spart)];
return hdrInfo;
}
function expBase(oS, a, t)
{
if (t.fExpanded)
return;
if (a[t.base] != null)
expBase(oS, a, a[t.base]);
t.fExpanded = true;
var oSchm = oS.schemas[t.nsuri];
var oSuper = oSchm.types[t.base];
if (oSuper == null || t.derivedType == null)
return;
for (var x in oSuper)
if (t.derivedType[x] == null)
t.derivedType[x] = oSuper[x];
}
Norwaywoods 2003-02-17
  • 打赏
  • 举报
回复
function onImportLoaded(oS)
{
for (var i = 0; i < oS.imports.length; i++)
{
if ( oS.imports[i] == null
|| !oS.imports[i].fPending
|| oS.imports[i].XMLDocument.readyState!=4)
continue;
var oImp = oS.imports[i].documentElement;
if (oImp == null)
continue;
oS.imports[i].fPending = false;
oS.cImporting --;
var xmlSdl = oS._oXml.documentElement;
switch (oImp.baseName)
{
case "definitions" :
for (var j = 0; j < oImp.attributes.length; j++)
{
var oAtt = oImp.attributes.item(j);
if (oAtt.name == "xmlns")
continue;
var ii = oAtt.name.indexOf("xmlns:");
if (ii != 0)
continue;
var nsn = oAtt.name.substring(6, oAtt.name.length);
if (oS.ns[nsn] != null)
continue;
oS.ns[nsn] = oAtt.value;
oS.nsalias[oAtt.value] = nsn;
}
for (var j = oImp.childNodes.length - 1; j >= 0; j --)
xmlSdl.appendChild(oImp.childNodes[j]);
break;
case "types" :
case "message" :
case "portType" :
case "binding" :
case "service" :
xmlSdl.appendChild(oImp);
break;
default :
var nsq = getQualifier(xmlSdl.nodeName);
nsq = nsq.length == 0 ? "" : (nsq + ":");
var nt = oS._oXml.XMLDocument.createElement(nsq + "types");
xmlSdl.appendChild(nt);
nt.appendChild(oImp);
}
oS.imports[i].removeNode(true);
oS.imports[i] = null;
if (oS.cImporting == 0)
{
processService(oS);
return;
}
}
}

function loadImports(oS)//×°ÔØËùÓеÄImport½øÀ´µÄ½Úµã
{
var xmlSdl = oS._oXml.documentElement;
if (xmlSdl == null)
return true;
var nsq = getQualifier(xmlSdl.nodeName);
nsq = nsq.length == 0 ? "" : (nsq + ":");
var nImp = xmlSdl.selectNodes(nsq + "import");//·µ»ØÒ»¸ö°üº¬ËùÓеġ°import¡±Ä£Ê½µÄXmlnodeµÄlist.
if (nImp.length == 0)
return true;
oS.imports = new Array();
oS.cImporting = 0;
for (var i = 0; i < nImp.length; i++)
{
var oImp = document.createElement("XML");
document.body.appendChild(oImp);
oImp.fPending = true;
oS.imports[i] = oImp;
oImp.onreadystatechange = function() {onImportLoaded(oS)};
var impUrl = getAttrib(nImp[i], "location");
if (impUrl == null)
continue;
oS.cImporting ++;
oImp.src = impUrl;
}
return false;
}

function invokeNext(svcName)
{
var oS = _sdl[svcName];
if (oS == null)
return;
var oC = oS.nextCall;
if (oC == null)
return null;
oS.nextCall = oC.next;
if (oS.nextCall == null)
oS.lastCall = null;
_invoke(oC);
}

function callNext(oS)
{
if (oS.fSeq)
setTimeout(element.uniqueID + '.invokeNext("' + oS.url + '")', 0);
}

function getAttrib(o, sAName)
{
if (o.attributes == null)
return null;
var a = o.attributes.getNamedItem(sAName);
if (a != null)
return a.value;
return null;
}

function getBaseName(str)
{
var a = str.split(":");
if (a.length > 1)
return a[1];
return str;
}

function getQualifier(str)
{
var a = str.split(":");
if (a.length > 1)
return a[0];
return '';
}

function getNextNsq(oS)
{
var nsq1;
do
{
nsq1 = "mswsb" + _nextNsQ;
_nextNsQ ++;
}
while (oS.ns[nsq1] != null)
return nsq1;
}

function getUniqueNsq(oS, o, litNsq)
{
if (litNsq == null)
return litNsq;
var nsuri = null;
if (litNsq == '')
nsuri = o.namespaceURI;
else
{
var o1 = o;
while (o1 != null)
{
nsuri = getAttrib(o1, 'xmlns:'+litNsq);
if (nsuri != null)
break;
o1 = o1.parentNode;
}
}
if (nsuri == null)
return litNsq;
var nsq1 = oS.nsalias[nsuri];
if (nsq1 != null)
return nsq1;
litNsq = getNextNsq(oS);
oS.ns[litNsq] = nsuri;
oS.nsalias[nsuri] = litNsq;
return litNsq;
}

function parseSimpleType(oS, oschm, o, ssffx)
{
var ns = getQualifier(o.tagName);
var o1 = o.firstChild;
if (o1 == null)
return null;
var sn = getAttrib(o, "name");
if (sn == null)
return null;
sn = getBaseName(sn);
var ot = new Object();
ot.name = sn;
switch(o1.baseName)
{
case 'restriction' :
var base = getAttrib(o1, "base");
if (base == null)
{
ot.ns = "xsd";
ot.type = "string";
}
else
{
ot.type = getBaseName(base);
ot.ns = getQualifier(base);
}
oschm.sTypes[sn] = ot;
break;
case 'list' :
case 'union' :
ot.type = "string";
ot.ns = "xsd";
oschm.sTypes[sn] = ot;
break;
default:
ot = null;
}
return ot;
}
goldencode 2003-01-30
  • 打赏
  • 举报
回复
是的可以编译成功但一定要有JET的库而且要在它的安装目录下自己乱拷还不行。
这样怎么分发啊。
goldencode 2003-01-29
  • 打赏
  • 举报
回复
我这几天找了一下,
本地编译器不太多
主要是
jet
jove
IBM HPJ
SuperCede
NativeJ
GCJ
TowerJ
Visual Cafe
FastJ
但坏消息是他们除了GCJ都是收费的,而且GCJ目前虽然可以在Linux上交叉编译
Window的exe但目前不支持AWT和SWING,最贵的是IBM的HPJ 要3千多美刀!他也是性能最好的.
这些工具比较专,所以没找到任何注册骂:(
看来只有IBM的visualAge了,为什么? 大家自己去想吧。
用visualAge成功的或者找到以上软件注册码的请说一说:D
noblame 2003-01-29
  • 打赏
  • 举报
回复
Excelsior JET 3.0完全可以!!!并且它的个人版是免费的。

Excelsior JET 3.0, Standard Edition is the fast track solution for compilation of self-contained Java applications to native code.
Excelsior JET transforms your Java applications into conventional Microsoft Windows executables that work faster, consume less memory, and are much more resistant to reverse engineering by third parties.

Superior Application Performance. Excelsior JET makes your Java programs run at the speed of C/C++ programs through the extensive use of classical optimizations and object-oriented optimizations carefully adapted to Java.
Superior Code Protection. Excelsior JET helps you protect your intellectual property: instead of Java class files, extremely easy to reverse engineer, your end users receive highly optimized native code executables that are much less comprehensible.
Superior Scalability. Elimination of the virtual machine and run-time compilation from the execution process, extremely low heap overhead, and automatic sharing of code and data between processes at the operating system level dramatically reduce the memory footprint of your Java applications.
Easy Deployment. The JetPack utility packages your application files into a self-installing archive. Upon startup, that archive may optionally display your splash screen and license agreement. Then it launches a GUI wizard allowing the user to specify installation directories and the like.
Smooth toolchain integration. Excelsior JET has extremely low impact on your established development cycle. You continue using your favorite tools for the most important stages: design, coding, debugging, and testing, without any changes. Once your application works stable on a virtual machine, you compile and package it with JET, conduct quality assurance testing and deploy to enduser systems.
FEATURES



Highly optimizing compiler producing conventional Windows EXE and DLL files
JET Control Panel (graphical front-end)
Support for all J2SE 1.3.0-1.4.1 platform packages (including AWT/Swing), JNI and Invocation API
Limited support for Java dynamic class loading
Interoperability with C/C++/Deplhi via JNI and Invocation API
NEW Interoperability with C++/VB6/VBA via COM
NEW NT Services toolkit
Resource binding
JetPack utility for easy deployment
Royalty-free high performance run-time library
Documentation in JavaHelp and PDF formats
Sample programs
30 days Getting Started Support
(optional) 1 Year of Standard Support
(optional) 1 Year of Maintenance

这是标准版的介绍,个人版功能也差不多,主要是个技术支持的问题。
我已经用它将一个java程序编译成了windows下的.exe文件。看看它的BENEFITS就知道了



Norwaywoods 2003-01-27
  • 打赏
  • 举报
回复
能不能说具体一点,最好是免费的东西。
xiaofenguser 2003-01-27
  • 打赏
  • 举报
回复
听说sun有一种原生码编译器
goldencode 2003-01-27
  • 打赏
  • 举报
回复
哈哈,
好象IBM的visualAge 也可以。
Norwaywoods 2003-01-27
  • 打赏
  • 举报
回复
我还是自己回答吧:
JIT
Norwaywoods 2003-01-27
  • 打赏
  • 举报
回复
能不能具体一点呀!
takecare 2003-01-27
  • 打赏
  • 举报
回复
javac
java.sun.com

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧