Frequently Asked Questions (FAQ)
Stay organized with collections
Save and categorize content based on your preferences.
I'm having problems building with Xcode.
See Debugging Build Problems.
How do I fix "undefined symbol" errors when building?
See Required Link Settings.
I'm having problems using j2objc on the command-line.
The fastest way to come up with a command-line for j2objc is to start with javac, specifying the
classpath (optional), sourcepath (optional), output directory, and list of source files. Once that
compiles successfully, substitute "j2objc" for "javac", and add any j2objc-specific flags. The
reason this works is that j2objc uses a Java compiler as it's front-end, and so uses the same
arguments as the compiler. Remember: if it doesn't compile, it can't be translated!
How is garbage collection handled?
See Memory Management. We continue to refine generated code to improve how
memory is managed, using Xcode's leak detection and profiling tools. We encourage projects using
J2ObjC to also monitor performance and leak detection (as all iOS projects should), and to report
any issues found.
How can the translated code size be reduced? What can speed up translation?
See Dead Code Elimination.
How does j2objc handle imports inside of .java files?
j2objc uses the javac compiler as its front-end, so all imports are read as any
Java compiler would do. To specify where to find imported classes, use the same -classpath and
-sourcepath options you would use with javac. When generating Objective-C files, external class
references are gathered, and #import
directives are added to either the generated header (.h) or
implementation (.m) files as appropriate.
Why are some of the minimum and maximum values for numeric types different from the Java specification?
These values are different from what Java returns because they are outside what the Objective-C
compiler will accept as valid. We instead use the minimum and maximum values defined in
/usr/include/values.h.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThis page provides troubleshooting information for common issues encountered when using j2objc, such as Xcode build problems and command-line usage.\u003c/p\u003e\n"],["\u003cp\u003eUsers can find guidance on resolving "undefined symbol" errors, managing memory and garbage collection, and reducing translated code size.\u003c/p\u003e\n"],["\u003cp\u003eThe document explains how j2objc handles imports, mirroring the behavior of the javac compiler for class resolution and utilizing \u003ccode\u003e#import\u003c/code\u003e directives in generated Objective-C files.\u003c/p\u003e\n"],["\u003cp\u003eIt addresses discrepancies in numeric type limits, attributing them to differences between Java specifications and Objective-C compiler constraints, with values sourced from /usr/include/values.h.\u003c/p\u003e\n"]]],[],null,["# Frequently Asked Questions (FAQ)\n\n### I'm having problems building with Xcode.\n\nSee [Debugging Build Problems](/j2objc/guides/xcode-build-rules#debugging_build_problems).\n\n### How do I fix \"undefined symbol\" errors when building?\n\nSee [Required Link Settings](/j2objc/guides/required-link-flags).\n\n### I'm having problems using j2objc on the command-line.\n\nThe fastest way to come up with a command-line for j2objc is to start with javac, specifying the\nclasspath (optional), sourcepath (optional), output directory, and list of source files. Once that\ncompiles successfully, substitute \"j2objc\" for \"javac\", and add any j2objc-specific flags. The\nreason this works is that j2objc uses a Java compiler as it's front-end, and so uses the same\narguments as the compiler. Remember: if it doesn't compile, it can't be translated!\n\n### How is garbage collection handled?\n\nSee [Memory Management](/j2objc/guides/memory-management). We continue to refine generated code to improve how\nmemory is managed, using Xcode's leak detection and profiling tools. We encourage projects using\nJ2ObjC to also monitor performance and leak detection (as all iOS projects should), and to report\nany issues found.\n\n### How can the translated code size be reduced? What can speed up translation?\n\nSee [Dead Code Elimination](/j2objc/guides/dead-code-elimination).\n\n### How does j2objc handle imports inside of .java files?\n\nj2objc uses the javac compiler as its front-end, so all imports are read as any\nJava compiler would do. To specify where to find imported classes, use the same -classpath and\n-sourcepath options you would use with javac. When generating Objective-C files, external class\nreferences are gathered, and `#import` directives are added to either the generated header (.h) or\nimplementation (.m) files as appropriate.\n\n### Why are some of the minimum and maximum values for numeric types different from the Java specification?\n\nThese values are different from what Java returns because they are outside what the Objective-C\ncompiler will accept as valid. We instead use the minimum and maximum values defined in\n/usr/include/values.h."]]