Cant run j2objc

71 views
Skip to first unread message

Assaf Yehudai

unread,
Jan 16, 2023, 8:50:35 AM1/16/23
to j2objc-discuss

assafyehudai@Assafs-Agritask-MBP-M1 ~ % cd Developer/Java/j2objc-master/scripts 

assafyehudai@Assafs-Agritask-MBP-M1 scripts % $j2objc -d ../../output -sourcepath ../../javasource/common/mobile/src                 

zsh: command not found: -d

assafyehudai@Assafs-Agritask-MBP-M1 scripts % 

Hi Tom,
am I doing something wrong?

thanks.

Tom Ball

unread,
Jan 16, 2023, 11:44:25 AM1/16/23
to j2objc-...@googlegroups.com
I don't mean to sound harsh, but first go through a good shell (command line) tutorial? The "j2objc" is a Bash script, so this zsh error indicates it wasn't running. If you run "which j2objc", it likely is executing something other than the script from the j2objc release.

The Getting Started doc starts with "Download the current distribution from the Releases section and unzip it." That should create a "j2objc-2.8" directory, and running "j2objc-2.8/j2objc" should run the j2objc command and display its flags. Once that shows, you'll know you are running the right app. 

Since j2objc's front-end is actually javac, the best starting out advice is to first figure out how to compile your library's source files with a javac command, then replace "javac" in that command with the "j2objc-2.8/j2objc" command. That means that your command is incomplete, since it doesn't specify any source files after the -sourcepath argument.

For what it's worth, j2objc is an advanced build tool for medium-to-very-large apps (Gmail size), not a way to avoid learning iOS. It's more work to set it up for small apps than can ever be saved from code sharing. That's especially true if the app's code is mostly for its user interface. If most of your Java sources start with "import android.*", it will save time, effort, and frustration to instead rewrite the app from scratch in Objective-C (Java and Objective-C are more similar than developers assume from looking at examples).

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/j2objc-discuss/09ef1628-ab24-44e6-ba9f-3879ea5ec0a3n%40googlegroups.com.

Assaf Yehudai

unread,
Jan 17, 2023, 9:00:01 AM1/17/23
to j2objc-discuss
Hey Tom, 
Thanks for the response, no harshness taken, I never had the opportunity of using the command line more then running the obvious copy paste commands needed for simpler projects,
with that being said Ill definitely take your advice in the matter.
As for the my need with the j2objc project, please trust me that i'm using it for the moment for the right reasons.

Now, to be honest I missed the part where I was suppose to build the project, so I'm on it, but I got an error:   

Environment:

HOME=/Users/assafyehudai

HOMEBREW_CELLAR=/opt/homebrew/Cellar

HOMEBREW_PREFIX=/opt/homebrew

HOMEBREW_REPOSITORY=/opt/homebrew

INFOPATH=/opt/homebrew/share/info:

J2OBJC_ARCHS=macosx iphone64 iphone64e watchosv7k watchos64 watchsimulator watchsimulator64 simulator simulator64 maccatalyst appletvos appletvsimulator macosx64 maccatalyst64

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.17.jdk/Contents/Home

LC_CTYPE=UTF-8

LOGNAME=assafyehudai

MAKEFLAGS=

MAKELEVEL=1

MANPATH=/opt/homebrew/share/man::

MFLAGS=

PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

PROTOBUF_ROOT_DIR=/usr/local

PWD=/Users/assafyehudai/Developer/Java/j2objc-master

SHELL=/bin/zsh

SHLVL=2

SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VDBQ8uNdje/Listeners

TERM=xterm-256color

TERM_PROGRAM=Apple_Terminal

TERM_PROGRAM_VERSION=447

TERM_SESSION_ID=7D2CEEC9-FF26-4C29-B696-2DFDB7EFD9E0

TMPDIR=/var/folders/kk/n8919bc967z7q4cnx8d1z93h0000gn/T/

USER=assafyehudai

XPC_FLAGS=0x0

XPC_SERVICE_NAME=0


Building j2objc annotations

mvn -q generate-resources dependency:sources

building j2objc jar

Note: src/main/java/com/google/devtools/j2objc/pipeline/InputFilePreprocessor.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

building jre_emul.jar

building jre_emul-src.jar

building json.jar

android/platform/libcore/ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java:34: error: duplicate class: java.lang.invoke.MethodHandles

public class MethodHandles {

       ^

1 error

make[1]: *** [/Users/assafyehudai/Developer/Java/j2objc-master/jre_emul/build_result/json.jar] Error 1

make: *** [jre_emul_jars_dist] Error 2

Tom Ball

unread,
Jan 17, 2023, 10:41:35 AM1/17/23
to j2objc-...@googlegroups.com
I don't know why you're getting the duplicate class error, but you don't need to build the project. Just download the latest version from our releases page, unzip it and (optionally) add the path it creates to your PATH environment variable.

Reply all
Reply to author
Forward
0 new messages