|
UsageGuide
how to use java2objc to convert Java code to Objective C
Featured IntroductionAt the moment, there is no standalone java2objc tool that you can run to convert Java code to Objective C. This is because this project is still in progress and is meant for those willing to work with java2objc source-code. Details1. Creating a java2objc Eclipse project: Note: java2objc uses maven2.
2. Steps to produce Objective C code using java2objc: In the instructions below, I will show how to generate Objective C code for the example Java class examples/examples/AssortedExamples.java
|
Can you please provide more details on development environment for trying this out? I'm using Mac and latest eclipse. Not able to get this working. For example, under Run | Run Configuration, I don't see a place I choose com.google.code.java2objc.main.Main.
Was this tested on Linux and using Eclipse ? version
Good work Inder.
I have built a binary from the trunk. For the lazy ones who want to run it without much effort, the binaries are bundled here : https://docs.google.com/leaf?id=0B27YZyyr4AC_M2Y1NGVhY2MtNTk3Ni00ODAyLWExMmQtYTQwNjhkYTk5NzU3&hl=en
The output objective C is generated in output folder. Just follow the readme
Good luck.
I've built a binary containing changes I've made to java2objc. It is now much more stable, supports many more language features, and works on folders as well as individual Java files. As with the above binary, follow the readme to use it. You can download it here: https://docs.google.com/leaf?id=0Bw10lZcgyg19NWJkNzNiZTYtYzQ1MS00ZDY3LWE3MGMtYmFiNWQzN2NkMTdl&sort=name&layout=list&num=50
Have you tried compiling the compiler? so to create an objective-C version of your application?
See the third bullet point in the front page: "The generated code is not likely to have the exact same behavior and may not even compile. The generated code is a mere suggestion. A human should look at the generated code and tweak it automatically." Converting this tool to Objective-C would take a lot of additional work on the source code. In addition it depends on the javaparser library which would also have to be converted.
This tool is really meant to give you a head-start for porting code. I used my heavily-modified version above to convert a real world application's code for an iOS port. After conversion the code still needed a fair bit of work to make it compile (mainly related to using Cocoa instead of the Java standard library), and further changes to make it run successfully (mainly related to memory management). The languages are different enough that I think a fully automated conversion tool would be impractical, but this tool can save you a good deal of work.
We are using this tool to port POJO to obj-C code. But the major issue that we face is when the Java method returns an Interface. Eg. (ITempInterface)tempMethod is actually to be ported as (id<ITempInterface>)tempMethod but it is ported as (ITempInterface)tempMethod and that causes a lot of issues. Can we by some means detect if a particular guy is an interface and port it accordingly.
nice work :)
Current codeset no longer runs; After extracting the latest source :
INFO? ------------------------------------------------------------------------ ERROR? BUILD ERROR INFO? ------------------------------------------------------------------------ INFO? One or more required plugin parameters are invalid/missing for 'eclipse:configure-workspace'
0? Inside the definition for plugin 'maven-eclipse-plugin' specify the following:
<configuration>
</configuration>-OR-
on the command line, specify: '-Declipse.workspace=VALUE'
INFO? ------------------------------------------------------------------------ INFO? For more information, run Maven with the -e switch INFO? ------------------------------------------------------------------------ INFO? Total time: 25 seconds INFO? Finished at: Sun Aug 12 14:12:22 NZST 2012 INFO? Final Memory: 10M/302M
After run with: ~/apps/apache-maven-2.2.1/bin/mvn eclipse:configure-workspace eclipse:eclipse
OS: Linux (Ubuntu 12.04.2, 64 bits)
I am continuously getting this error while running the j2Objc Project
"The method getPakage() is undefined for the type CompilationUnit?" CompilationUnitConverter?.java