1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
This commit is contained in:
Quinton Ashley 2022-02-21 11:32:58 -05:00
parent e11bf077f8
commit 28c28d298a
4 changed files with 9 additions and 5 deletions

View File

@ -54,7 +54,7 @@ The java2js transpiler supports:
This function imports the standard java.lang classes into the global scope. You must use it before translating or running files.
- root (optional) path to the parent folder of the JS `jdk` folder, by default it is `.` (the current directory) you could also link to this package online 'https://unpkg.com/java2js'
- root (optional) path to the JS JDK folder, by default it is `./jdk` (the java2js JS JDK), for online use on codepen or similar code sharing sites you can use this link as the root path: 'https://unpkg.com/java2js/jdk'
### await jdk.transpile(javaFile)
@ -95,3 +95,7 @@ This project builds upon the [java-to-javascript](https://github.com/wyattades/j
## Contribute
I've only done a partial implementation of the Java 17 JDK in JavaScript, so if you're interested in adding more please go for it and submit a pull request!
## Commercial Use
This project is licensed under the copyleft GNU GENERAL PUBLIC LICENSE 3.0 (only) license. If you'd like to request legal permission to use this code in a commerical product or closed source project please email me (qashto@gmail.com) with a proposal of how you would like to use `java2js`.

View File

@ -1,6 +1,6 @@
(async () => {
jdk.log = document.getElementById('javaConsole');
await jdk.init('..');
await jdk.init('../jdk');
let file0 = document.getElementById('javaFile');
file0.onchange = async () => {

4
jdk.js
View File

@ -48,7 +48,7 @@
constructor() {}
async init(root) {
this.root = root || '.';
this.root = root || './jdk';
this.java = {};
let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util'];
for (let pkg of pkgs) {
@ -129,7 +129,7 @@
imp.load = null;
imp.classPath = className.split('.');
let src = this.root + '/jdk';
let src = this.root;
for (let part of imp.classPath) {
src += '/' + part;
}

View File

@ -1,6 +1,6 @@
{
"name": "java2js",
"version": "1.1.11",
"version": "1.1.12",
"description": "Converts Java to JavaScript and runs it with a JS JDK",
"main": "jdk.js",
"scripts": {