Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 23, 2021. It is now read-only.
/j2js-compilerPublic archive

⚠️ Deprecated. A Java Bytecode to JavaScript Cross-Compiler.

License

NotificationsYou must be signed in to change notification settings

decatur/j2js-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Deprecated. Consider to adopt the TypeScript eco system.

A lightweight component to expose computational MATLAB resources over HTTP.

#j2js-compiler

A Java Bytecode to JavaScript Cross-Compiler.

##Installation

  1. You need to install this and the following projects
  1. Build all projects. An Eclipse project description is included.

  2. Optionally installhttps://github.com/decatur/j2js-demos

##Building your project

It is highly recommended that you compile your project (i.e. generate class files) againstj2js-jre, and notrt.jar. This way you avoid link errors (missing classes or methods) at the cross-compile stage. See the warning at the bottom of the document.

##Usage

java -cp <RUNTIME_CLASSPATH> com.j2js.J2JSCompiler <basedir> <CROSS_COMPILE_CLASSPATH> <entryPointClassName> <targetLocation>

###<RUNTIME_CLASSPATH>

This is the standard Java classpath.The cross-compiler needs the project j2js-compiler, bcel and commons-io on its classpath.

###<basedir>

All non-absolute paths are relative to the basedir.

###<entryPointClassName>

The name of the class to cross-compile. This class must have a methodpublic void main(java.lang.String[]).

The compiler cross-compiles themain method and all other methods which are called from themain method.

###<CROSS_COMPILE_CLASSPATH>

This classpath must contain all classes whose methods are referenced by the main method.In normal operation, this classpath consists of

  • the j2js-jre classes directory or jar
  • the j2js-agent classes directory or jar
  • the classes directory of your personal project

###<targetLocation>All cross-compiled code is stored in the target location. It is one or more JavaScript file starting at0.js. Only this initial file must be included in your web page with<script src='targetLocation/0.js'/>.

###Example

Suppose the directory layout is

|- j2js-compiler|- j2js-jre|- j2js-agent|- my-project     |- target         |- assemblies             |- 0.js             |- 1.js             |- 2.js ...

and you want to cross-compile classorg.mydomain.my-project.MyClass. Then

java -cp ../j2js-compiler/libs/commons-io-1.4.jar;^../j2js-compiler/libs/bcel-5.1.jar;^../j2js-compiler/target/classes ^com.j2js.J2JSCompiler . ^target/classes;../j2js-jre/target/classes;../j2js-agent/target/classes ^org.mydomain.my-project.MyClass target/assemblies

will create the assemblies.

##WarningThe projectj2js-jre contains a hand-crafted version of the Java Runtime Environment. Do not putJava/jreX/lib/rt.jar into the<CROSS_COMPILE_CLASSPATH>.

##LimitationsThe cross-compiler is able to translate any legal Java Bytecode. However, naturally, the compiler cannot support the Java Native Interface (JNI).

##Cross Compiling ScalaThe current Scala version uses JRE classes such asClassLoader orSecurityContext even in base Scala classes. These JRE classes do not make sense in a web agent context and are therefore not implemented inj2js-jre.

A workaround would be to hand-craft a subset of Scala classes, avoiding dependencies to JRE classes such asClassLoader. But this is a lot of work.

So, sadly, we cannot support Scala under this circumstance.

About

⚠️ Deprecated. A Java Bytecode to JavaScript Cross-Compiler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp