juniversal / juniversal Goto Github PK
View Code? Open in Web Editor NEWWrite cross platform mobile apps, in Java
Home Page: http://juniversal.org
License: MIT License
Write cross platform mobile apps, in Java
Home Page: http://juniversal.org
License: MIT License
We try to convert code which uses multidimensional arrays (and initializers) a lot. But it seems that JUniversal doesn't support it.
I see the website says
You’ll see a lot of C++ code get generated, but it’s only partially baked at this point, so don’t expect it to work.
so maybe I'm trying this too early. I build a "hello world" app from Java to C++, then tried to compile that using clang, but I get errors in the support headers,
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
In file included from hello.h:4:
In file included from ../juniversal/cpp-archive/cpplib/src/juniversal.h:7:
../juniversal/cpp-archive/cpplib/src/juniversal_defs.h:28:33: error: reinterpret_cast from 'char' to 'unsigned char' is not allowed
return reinterpret_cast<char>( reinterpret_cast<unsigned char>(value) >> bits );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../juniversal/cpp-archive/cpplib/src/juniversal_defs.h:32:34: error: reinterpret_cast from 'short' to 'unsigned short' is not allowed
return reinterpret_cast<short>( reinterpret_cast<unsigned short>(value) >> bits );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../juniversal/cpp-archive/cpplib/src/juniversal_defs.h:36:32: error: reinterpret_cast from 'int' to 'unsigned int' is not allowed
return reinterpret_cast<int>( reinterpret_cast<unsigned int>(value) >> bits );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../juniversal/cpp-archive/cpplib/src/juniversal_defs.h:40:35: error: reinterpret_cast from 'long64' (aka 'long long') to 'ulong64' (aka 'unsigned long long') is not allowed
return reinterpret_cast<long64>( reinterpret_cast<ulong64>(value) >> bits );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Turning those into static casts, it gets past those and into some other errors. (I see the same error on gcc, so it doesn't look like a clang bug.)
I can submit a pull request with those fixes, if that would be helpful?
Overall, what is the state of C++ support? Is it too early to test and file bugs/submit pull requests?
I have two proposal.
d like a refrection to use a type safe cast in a method of generic type. Because, "Instanceof" operator doesn
t work well in generic type.Just found this library and it sounds very promising before I give it a try I have some question I couldn't find answers on the website:
How is translation of java to c# working?
If transpiled what java packages from jdk are supported or are they also transpiled on the fly?
This was reported by someone using JUniversal (Satoshi), but I'm adding it here just for tracking purposes.
No visitor found for class org.eclipse.jdt.core.dom.TypeLiteral Error In this code as below, we have an error as above.
--- This is sample code to reproduce the error.
package main.java.test
public class TestClass {
static public String test(){
return testKey( SomeClass.class );
}
public static interface SomeClass {
}
protected static String testKey( Class<?> key ) {
return key.getName();
}
}
We can't resolve this error.
Of course, it works well on Java.
It looks promising. J2OBJC takes care of java to objective-c. has it reached the same level of maturity like juniversal?
We are evaluating this kind of tools for writing business logic in common language and UI in platform specific.
J2OBJC is quite good but doesn't support windows platform.
DJINNI by dropbox does good job but learning curve(CPP is daunting ) and will not find many open source libraries like java.
I'm trying to config Gradle file to use JUniversal plugin
this link : http://juniversal.org/getting-started/
At Running the translators on your code–Gradle plugins
In Android Studio Open Gradle File (app build.gredle)
it is >
apply plugin: 'com.android.application'
apply plugin: 'javaToObjectiveC'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.emaar.app.testbuild"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
mavenCentral()
maven{
url "${System.env.HOME}/env/maven/repository"
/ / url "https://maven-repository.dev.java.net/nonav/repository"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath group: 'org.juniversal', name: 'juniversal-gradle-plugins', version: '0.8-SNAPSHOT'
}
}
javaToObjectiveC {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
// compile 'org.juniversal:juniversal-gradle-plugins:0.8.3'
}
when I Sync project it shows me >
Error:Could not find org.juniversal:juniversal-gradle-plugins:0.8-SNAPSHOT.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/maven-metadata.xml
file:/Applications/Android Studio.app/Contents/gradle/m2repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.jar
https://jcenter.bintray.com/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/maven-metadata.xml
https://jcenter.bintray.com/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.pom
https://jcenter.bintray.com/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.jar
https://repo1.maven.org/maven2/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/maven-metadata.xml
https://repo1.maven.org/maven2/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.pom
https://repo1.maven.org/maven2/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.jar
file:/Users/emaar/env/maven/repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/maven-metadata.xml
file:/Users/emaar/env/maven/repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.pom
file:/Users/emaar/env/maven/repository/org/juniversal/juniversal-gradle-plugins/0.8-SNAPSHOT/juniversal-gradle-plugins-0.8-SNAPSHOT.jar
Required by:
TestBuild:app:unspecified
How to fix it ?
Most String methods seem to be unsupported by the translator (toLowerCase, replaceAll, and matches are a few I've found after a brief look). Also, it throws an error explaining that it's not supported, yet still shows BUILD SUCCESSFUL after the script runs. The output files are all blank so it wasn't actually successful with just warnings or the like.
OS: Mac OSX Yosemite
Action: javaToCSharp
IDE: Intellij14
Jsimple libraries are imported as JARs in the library. The IDE has no problem with those String methods even with them being imported from JSimple and not anywhere else, so it's strange that the error doesn't appear until compile time with gradle.
sample output:
./gradlew javaToCSharp
:javaToCSharp
/Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java
Translating /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java/Base32String.java
Error: Java method String.replaceAll isn't supported by the translator
File /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java/Base32String.java
80:43: encoded = encoded.trim().replaceAll(sSeparator, "")
^
Translating /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java/DataValidation.java
Error: Java method String.matches isn't supported by the translator
File /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java/DataValidation.java
37:26: if(!domain.matches(
^
Translating /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/main/java/HelloWorld.java
Warning: -classpath path entry /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/build/resources/main does not exist; ignoring
Warning: -sourcepath path entry /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/test/java does not exist; ignoring
Error: Directory doesn't exist: /Users/hans.reichenbach/okta/hackathon/HackathonJUniversal/src/test/java
BUILD SUCCESSFUL
Total time: 3.585 secs
Hi
When I want to Translate Java codes to Objective-C with Command inc Mac Termnal >>
java -jar juniversal/juniversal-translator/build/libs/juniversal-translator-0.8.3.jar -o $HOME/javaoutput/objectivec/testbuild -l objectivec -classpath jsimple/libraries/jsimple-util/build/libs/jsimple-util-0.9.3.jar -sourcepath $HOME/androidstudioprojects/testbuild/app/src/main/java $HOME/androidstudioprojects/testbuild/app/src/test/java
Shows me error >>
Error: 'objectivec' is not a valid target language
I think it's Opening Ceremony Level
JetBrains released their decompiler a while ago (seems to be a vastly improved version of fernflower):
https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine
When the decompiled code is functionally identical to the original it might be worth a try to use it for the translation into other languages via JUniversal. This would probably require a mapper that maps certain type references to JSimple classes.
I felt happy to hear the news about JUniversal.
I have gone through the Juniversal page and I have same clarifications in that,
can any one please clear me on that?
Please clarify my questions.
Hello , am following this post to translate my android code to c# http://juniversal.org/getting-started/ , in the tutorial, the jar file had a snapshot "juniversal-translator-0.8-SNAPSHOT.jar" , I renamed that to "juniversal-translator-0.8.3.jar" , when I enter the command below , I get the output directory and empty file .
java -jar juniversal/juniversal-translator/build/libs/juniversal-translator-0.8.3.jar -o cSharpEdaura -l c# -classpath jsimple/libraries/jsimple-util/build/libs/jsimple-util-0.9.3.jar EdauraApp/edauramobileandroid/app/src/main/java/com/edaura/edauramobile/Courses
The result has a huge amount of errors of "cannot be resolved"
here is the first one :
Error: The import android cannot be resolved
File C:\Users\yahya\Downloads\EdauraApp\edauramobileandroid\app\src\main\java\com\edaura\edauramobile\Courses\ChooseMajorTeacherActivity.java
3:7: import android.content.Context;
^
Error: The import android cannot be resolved
File C:\Users\yahya\Downloads\EdauraApp\edauramobileandroid\app\src\main\java\com\edaura\edauramobile\Courses\ChooseMajorTeacherActivity.java
4:7: import android.content.Intent;
What am I missing?
Hi, I am using JUniversal to translate Java classes of android project to Objective-C after installing J2Objc And clone juniversal and jsimple on Mac OS X (Yosemite), when i run below command into terminal (build failed on test , so test excluded from build):
./gradlew build install javaToObjectiveC -x test
it shows me error :
:libraries:jsimple-io:javaToObjectiveC FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':libraries:jsimple-io:javaToObjectiveC'. Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 4
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Also the file .bash_profile in $HOME directory is defined :
export ANDROID_HOME=/usr/local/opt/android-sdk
export GRADLE_HOME=/Users/emaar/env/gradle
export M2_HOME=$HOME/env/maven
export JAVA_HOME2=/usr/libexec/java_home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
export J2OBJC_HOME=/Users/emaar/env/j2objc
export PATH=$PATH:$M2_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$GRADLE_HOME:$J2OBJC_HOME:$JAVA_HOME
when i use :
$ ./gradlew build install javaToCSharp -x test
it shows BUILD SUCCESSFUL with Nzo Error what did i wrong ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.