j2objc command to translate all the source files of a java project in a single command

904 views
Skip to first unread message

esprit...@gmail.com

unread,
Sep 12, 2013, 4:10:07 AM9/12/13
to j2objc-...@googlegroups.com
Hi,

I am using the following command to translate all the source files of a java project in a single command.but i am not able to achieve it.it misses some of the files.so anybody can help me in converting all the source files in a single stretch.

/Users/abc/Downloads/j2objc/j2objc -x objective-c -use-arc --verbose --ignore-missing-imports -sourcepath src//**.* -d /Users/abc/Documents/Generated_FIles/TestProject src//**//**//**//**//**//**//**.*

michael bishop

unread,
Sep 12, 2013, 4:31:36 AM9/12/13
to j2objc-...@googlegroups.com, esprit...@gmail.com
i was using this small bash script when i translated my source over

#!/bin/bash
shopt -s globstar
/dev/shm/j2objc-0.7.2/j2objc --ignore-missing-imports -sourcepath src --dead-code-report usage.txt -d obj-c src/**/*.java

Tom Ball

unread,
Sep 12, 2013, 10:19:43 AM9/12/13
to j2objc-discuss
I use the "find" command when doing one-off translations:

/Users/abc/Downloads/j2objc/jobjc -use-arc --verbose --sourcepath src -classpath ??? -d /Users/abc/Documents/Generated_Files/TestProject $(find src -name *.java)

I think your issue is in using the --ignore-missing-imports flag, as it's just used to get an initial assessment of how portable new code is. When imports aren't found, they are reported and no translation is done. That's necessary because the first stage of translation is running Eclipse's Java compiler to get a model of the code -- if Eclipse can't compile it because of a missing import, there's no model for translation.

The trick to translating without missing imports is to get the -sourcepath and -classpath flags right. The same paths can be used that would work with javac, so I suggest running "javac -classpath ??? -sourcepath ??? -d outpath $(find src -name *.java)" until all the flags are correct, then substituting "j2objc -use-arc" for "javac".

Tom





--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

michael bishop

unread,
Sep 12, 2013, 10:26:53 AM9/12/13
to j2objc-...@googlegroups.com
using find like that will cause errors if any element in the path contains whitespace, its more stable to use find -print0 and xargs -0 together, but java code isn't likely to have whitepspace in the path normally
Message has been deleted

sajjad...@gmail.com

unread,
Dec 26, 2017, 4:32:25 AM12/26/17
to j2objc-discuss
On Thursday, September 12, 2013 at 6:49:43 PM UTC+4:30, Tom Ball wrote:
> I use the "find" command when doing one-off translations:
>
>
> /Users/abc/Downloads/j2objc/jobjc -use-arc --verbose --sourcepath src -classpath ??? -d /Users/abc/Documents/Generated_Files/TestProject $(find src -name *.java)

Thank you this is worked for me but one notice
sourcepath flag must be use with 1 dash (-) like this : -sourcepath and i think "*.java" must be in double quotation.
for more flags see this :
https://github.com/google/j2objc/issues/358

Reply all
Reply to author
Forward
Message has been deleted
0 new messages