当前位置:网站首页>Ikvm of toolbox Net project new progress
Ikvm of toolbox Net project new progress
2022-07-01 12:37:00 【Dotnet cross platform】
One thing that is often discussed in various groups is .NET How to call Java The implementation of the , One of the most common scenarios is in encryption and decryption Java Key provided ,C# Can't decrypt , C# in byte The scope is [0,255], and Java Medium byte The scope is [-128,127], Because the password generator is java Unique , Other languages do not support (IOS,ANDROID,C#,.NET etc. ), since java So unique , The solution we used was Java Fan's .
Java and .NET It is the two main technologies of software development at present ,Java 8 Although it is an older technology , A lot of work has been done . therefore , When it comes to reusability , stay .NET Used in Java Libraries created in are a very common practice . Suppose you are already in Java A library has been developed in , And want to be in .NET Use it in projects , that IKVM.NET Help in .NET Use in Java library .
This is the protagonist we are going to introduce today IKVM.NET , IKVM.NET The project has a very long history , As early as 2006 In, I wrote an article on my blog 《 stay .NET Run on the platform Java Program -IKVM.NET introduction 》[1], IKVM.NET and Mono The same is .NET Open source prehistoric community projects ,IKVM It's a Java To .NET The compiler , and Mono yes .NET Framework The open source 、 Cross platform version .2017 year IKVM.NET The author decided to give up IKVM.NET Development of , Since then, some people in the community have diverged IKVM.NET And continue to work , Although the development work is not very active , But in the 2022 year 3 The development has been very active since January (https://github.com/ikvm-revived/ikvm)[2], Now we can fully support .NET 6 了 :

IKVM.NET There are three main components :
stay .NET Implemented in Java virtual machine : It has a use C#.NET Developed JVM, It provides bytecode conversion and verification , Class loading and other functions , The current support Java 8, This is also Java The most used version .
Java The class library .NET Realization : It basically uses OpenJDK[3] Project to achieve JDK library .
Support Java and .NET Interoperability tools :IKVM.NET Include the following tools :
a) ikvm:Java virtual machine : We can relate it to java.exe(“ Dynamic mode ”) Compare . It loads a class file and executes its main Method , If we pass the class file name as a parameter , Then it will be executable jar In the document Java Code . If we put a jar File is passed as a parameter , Then it will execute it .
b) ikvmc: take Java Bytecode is compiled into CIL, Is used to Java Classes and jar Compiled into .NET Assembly (“ Static mode ”). This tool will Java Bytecode to .NET DLL and exe. It will import... In the file Java Bytecode to .NET DLL. therefore , When we pass multiple jar File and class file , It will combine them and generate a single exe or DLL file . yes exe still DLL Depends on the class file passed and jar Whether the document has Main Method . If they have one Main Method , Then it will generate a exe, otherwise DLL.
c) ikvmstub: from .NET Assembly build Java Stub class : It is from .NET Assembly generates stub class files , So that we can aim at .NET The code to compile Java Code .ikvmstub Tools from .NET Assembly build Java stub .ikvmstub Reads the specified assembly and generates a containing Java Interface and stub class Java jar file .
IKVM.NET It is very useful for various software development schemes . Here are some examples of possibilities .
Plug in JVM Included in the distribution IKVM The application is Java The virtual machine .NET Realization . in many instances , You can use it as Java A direct alternative to . for example , No typing required “java -jar myapp.jar” To run the application , You can type :ikvm -jar myapp.jar
stay .NET Used in applications Java library ,IKVM.NET Include ikvmc, One Java Bytecode to .NET IL converter . If you have one Java library , You want to .NET Used in applications , And then run “ikvmc -target:library mylib.jar” To create “mylib.dll”. for example ,Apache FOP The project is a project with Java Write open source XSL-FO processor , Widely used from XML Source generation PDF file . With the help of IKVM.NET technology ,Apache FOP Can be used by any .NET Application usage .
use Java Development .NET Applications IKVM It provides you with a Java Development .NET The method of application . although IKVM.NET Excluding for .NET Of Java compiler , But you can use any Java Compiler will Java Source code compiled as JVM Bytecode , And then use “ikvmc -target:exe myapp.jar” To generate .NET Executable file . You can even use the included ikvmstub The application is Java The code uses .NET API.
Support platform
.NET Framework 4.6.1 And higher
.NET Core 3.1 And higher
.NET 5 And higher
Java SE 8
IkvmReference
IKVM Include support for generating Java The library is converted to .NET Assembly , This is a recently added feature , For details, please refer to IkvmReference design scheme [4]. To quote Java Install the package in the project of the library . Use IkvmReference To indicate what your project needs Java library .
example :
<ItemGroup>
<IkvmReference Include="..\..\ext\helloworld-2.0.jar" />
</ItemGroup> The output assembly will be generated as part of the project build process . Can be directed to IkvmReference Additional metadata is added to customize the generated assembly .
Identity: The identification of the project can be a) JAR Path to file b) The path to the directory or c) Other unimportant names .IkvmReferenceAssemblyName: By default , Use the rules defined by the specification to generate . To overwrite this , Please do this here .AssemblyNameAutomatic-Module-NameAssemblyVersion: By default , Use the rules defined by the specification to generate . To overwrite this , Please do this here .AssemblyVersionAutomatic-Module-NameDisableAutoAssemblyName: If you disable testing .trueAssemblyNameDisableAutoAssemblyVersion: If you disable testing .trueAssemblyVersionFallbackAssemblyName: If not provided or cannot be calculated , Please use this value .AssemblyNameFallbackAssemblyVersion: If not provided or cannot be calculated , Please use this value .AssemblyVersionCompile: Optional semicolon delimited Java List of classpath items , To compile into an assembly . By default , If the identification of the project is existing JAR File or directory ( Not yet supported ), Then this value is the value of the item . Support MSBuild Client references multiple JAR or .class file .IdentitySources: To be used during document generation Java Optional semicolon delimited list of source files .( Not yet in favor of )References: Optional semicolon separated list of other identification values , To specify as a reference to the current identity value . for example , Depend on if , Then include both as items , But in Metadata specifies The logo of .IkvmReferencefoo.jarbar.jarIkvmReferencebar.jarReferencesfoo.jarDebug: Indicates whether debug symbols are generated ( It's not portable ) Optional Boolean value of . By default , This is determined according to the overall setting of the project .MSBuild All other metadata supported by item group definitions .
Reference
IkvmReference Not transferable . Including it in one project and adding a dependency to that project from the second project does not result in the same reference being provided on the second project . Instead, add a reference to each project .
For each project to resolve to the same generated assembly , Make sure that the settings are the same .
<ItemGroup>
<IkvmReference Include="helloworld.jar">
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</IkvmReference>
<IkvmReference Include="helloworld-2.jar">
<AssemblyName>helloworld-2</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<References>helloworld.jar</References>
<Aliases>helloworld2</Aliases>
</IkvmReference>
</ItemGroup>Related links :
[1] stay .NET Run on the platform Java Program -IKVM.NET introduction :https://www.cnblogs.com/shanyou/articles/343118.html
[2]ikvm Github Resurrection warehouse : https://github.com/ikvm-revived/ikvm
[3]OpenJDK: http://openjdk.java.net/
[4]IkvmReference design scheme :https://github.com/ikvm-revived/ikvm/issues/54
边栏推荐
- Four years after graduation: work, resign, get married, buy a house
- Ipv6-6to4 experiment
- Application of stack -- bracket matching problem
- Eurake分区理解
- What are the PHP FPM configuration parameters
- Wechat simulated geographical location_ Camouflage wechat location
- Compile and debug net6 source code
- [20211129] configuration du serveur distant du carnet de notes jupyter
- leetcode:241. 为运算表达式设计优先级【dfs + eval】
- 微信小程序 – 80个实用的微信小程序项目实例
猜你喜欢

Nc100 converts strings to integers (ATOI)

VS Code 设置代码自动保存

Four years after graduation: work, resign, get married, buy a house
![[Suanli network] technological innovation of Suanli Network -- key technology of operation service](/img/80/6e3648c88d309516d4bc29db9c153c.jpg)
[Suanli network] technological innovation of Suanli Network -- key technology of operation service

基因检测,如何帮助患者对抗疾病?

Sleep quality today 79 points

【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告
![[20211129] jupyter notebook remote server configuration](/img/7c/79c9fcb91bde75e954dc3ecf9f5afd.png)
[20211129] jupyter notebook remote server configuration

数论基础及其代码实现

Mobile note application
随机推荐
腾讯总考epoll, 很烦
[JS advanced] promise explanation
栈的应用——括号匹配问题
本科毕业四年:工作,辞职,结婚,买房
木架的场景功能
华为面试题: 招聘
数字信号处理——线性相位型(Ⅱ、Ⅳ型)FIR滤波器设计(2)
R语言使用yardstick包的conf_mat函数计算多分类(Multiclass)模型在每个交叉验证(或者重采样)的每一折fold上的混淆矩阵、并使用summary输出每个fold的其它详细指标
硬阈值(Hard Thresholding)函数解读[通俗易懂]
Circular linked list--
Four years after graduation: work, resign, get married, buy a house
Chain storage of binary tree
类的初始化与实例化
fatal error: execution: 没有那个文件或目录
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
localtime居然不可重入,踩坑了
用.Net Core接入微信公众号开发
晓看天色暮看云,美图欣赏
[20211129] configuration du serveur distant du carnet de notes jupyter
强大、好用、适合程序员/软件开发者的专业编辑器/笔记软件综合评测和全面推荐