Installation - J2OBJC Compiler

1,487 views
Skip to first unread message

mytc...@gmail.com

unread,
Dec 8, 2014, 4:44:43 PM12/8/14
to j2objc-...@googlegroups.com
Down loaded and unzipped from https://github.com/google/j2objc. on mac. Did not appear to install anything as per instruction http://hemantasapkota.github.io/posts/j2objc-eclipse-plugin/. What am I doing wrong?

Bruno

unread,
Dec 8, 2014, 4:47:13 PM12/8/14
to j2objc-...@googlegroups.com
The releases are just ZIP files with the compiled binary inside, no install. I'd suggest starting with the wiki:


On Mon, Dec 8, 2014 at 1:44 PM, <mytc...@gmail.com> wrote:
Down loaded and unzipped from https://github.com/google/j2objc. on mac. Did not appear to install anything as per instruction http://hemantasapkota.github.io/posts/j2objc-eclipse-plugin/. What am I doing wrong?

--
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/d/optout.



--

mytc...@gmail.com

unread,
Dec 9, 2014, 7:48:56 AM12/9/14
to j2objc-...@googlegroups.com
Thanks for your help. Downloaded new version. Getting message "Executing with switches: [ -g --no-package-directories -x objective-c -use-arc --verbose --ignore-missing-imports  ]

No Output directory specified. Files will not be exported." when I try to convert my Java app. What do I need to do? Thanks again for help. Happy to send more info if needed

mytc...@gmail.com

unread,
Dec 9, 2014, 9:15:32 AM12/9/14
to j2objc-...@googlegroups.com
Created output directory and now I get "Exporting ObjectiveC Files

Source Directory: /Users/user26868/Documents/workspace/mtc

Destination Directory: /Users/user26868/Desktop/output

Export finished." However no output found?


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

Bruno

unread,
Dec 9, 2014, 10:43:58 AM12/9/14
to j2objc-...@googlegroups.com
This sounds like an error from the Eclipse plugin, which I'm not familiar with.

My suggestion is to contact the plugin author: Hemanta Sapkota. I'm not sure if he's on the forum.

--
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/d/optout.

Bruno

unread,
Dec 9, 2014, 10:44:47 AM12/9/14
to j2objc-...@googlegroups.com
Also, see if there's a debug mode where it prints out the command line that it's running. Once you have that command line, it's easier to make changes and understand what j2objc is doing.

mytc...@gmail.com

unread,
Dec 9, 2014, 3:58:26 PM12/9/14
to j2objc-...@googlegroups.com
I'm getting nowhere using eclipse plug-in. Where can I find instructions to use j2objc outside of eclipse? 


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

Bruno

unread,
Dec 9, 2014, 4:37:19 PM12/9/14
to j2objc-...@googlegroups.com
Same as before: https://github.com/google/j2objc/wiki/Getting-Started

There's a "Build Integration" section on the right hand side.

--
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/d/optout.

mytc...@gmail.com

unread,
Dec 9, 2014, 5:54:28 PM12/9/14
to j2objc-...@googlegroups.com
Thanks - appears to run fine 


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

mytc...@gmail.com

unread,
Dec 10, 2014, 2:23:06 PM12/10/14
to j2objc-...@googlegroups.com

I used j2objc on windows 7 to translate java to xcode. I then created an xcode project on mac and added translated code. When I tried to build the project, I find that I need to add j2objc build rules. I read the documentation but it is difficult to follow. Probably because this is my first time using a mac. Am I on the right track or is there an easier way ( I hope)?  Thanks for all the help   


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

Bruno

unread,
Dec 10, 2014, 8:50:33 PM12/10/14
to j2objc-...@googlegroups.com
I would do all the development on a Mac since that's where the tools are primarily used. This is a pretty sophisticated tool and takes some sophistication to set up. Also the documentation is pretty good, so I would focus on studying that.

--
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/d/optout.

mytc...@gmail.com

unread,
Dec 11, 2014, 7:37:16 AM12/11/14
to j2objc-...@googlegroups.com

I’m sorry that I am still confused. From my understanding of the documentation it should make no difference where j2objc  is run. The generated files .h and .m should be the same. Once these files are added to an xcode project, I assume, all xcode needs to know is where to find j2objc files like #include "IOSClass.h" in order to build the project.  This is the error I am getting in the xcode project build. If this is the case it should be same place within the unzipped compiler file for everyone.  If you tell where I am going wrong  ,it would be very helpful. Thanks again


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

Tom Ball

unread,
Dec 11, 2014, 4:37:17 PM12/11/14
to j2objc-...@googlegroups.com
All .h files included with j2objc are in its include/ directory, and all libraries in its lib/ directory. The Xcode project needs its settings updated as described in the Xcode Build Rules wiki page. The Debugging Build Problems section below it is also helpful.

--

mytc...@gmail.com

unread,
Dec 12, 2014, 6:13:22 PM12/12/14
to j2objc-...@googlegroups.com


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem.pdf

Tom Ball

unread,
Dec 13, 2014, 1:22:55 AM12/13/14
to j2objc-...@googlegroups.com
Let me repeat: the Xcode Build Rules page describes the flags that need to be set. Step 1 says you need to add the path of the j2objc distribution's include directory in the Xcode project's Header Search Paths build setting. If, for example, you unzipped the distribution to /foo/bar/j2objc-0.9.5, then you need to add /foo/bar/j2objc-0.9.5/include to the Header Search Paths (not "j2objc/include", which doesn't refer to an actual directory on your system). If you don't do that, you get exactly the error you are reporting. 

On Fri Dec 12 2014 at 3:13:23 PM <mytc...@gmail.com> wrote:


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
Down loaded and unzipped from https://github.com/google/j2objc. on mac. Did not appear to install anything as per instruction http://hemantasapkota.github.io/posts/j2objc-eclipse-plugin/. What am I doing wrong?

--

mytc...@gmail.com

unread,
Dec 13, 2014, 12:45:20 PM12/13/14
to j2objc-...@googlegroups.com


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem3.pdf

Bruno

unread,
Dec 13, 2014, 7:03:54 PM12/13/14
to j2objc-...@googlegroups.com
From what I can see, your paths look correct. Check that the j2objc "include" folder contains the IOSClass.h file your expecting. I suspect that there's something wrong with your Xcode paths.

Failing that, click on the error and it will show you the command line used for the Xcode compiler. Look inside that command for the header path and again check that it's correct. Copy and paste it in to a terminal with an "ls" command in front to check that it exists.


On Sat, Dec 13, 2014 at 9:45 AM, <mytc...@gmail.com> wrote:


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
Down loaded and unzipped from https://github.com/google/j2objc. on mac. Did not appear to install anything as per instruction http://hemantasapkota.github.io/posts/j2objc-eclipse-plugin/. What am I doing wrong?

--
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/d/optout.

mytc...@gmail.com

unread,
Dec 14, 2014, 5:46:28 AM12/14/14
to j2objc-...@googlegroups.com


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem4.pdf

mytc...@gmail.com

unread,
Dec 14, 2014, 6:24:16 AM12/14/14
to j2objc-...@googlegroups.com
Noticed / missing before Users - Fixed and re-built. Now missing java/lang/process.h Do not see it in include, is it in a sub folder? Screen shot of error attached


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem5.pdf

mytc...@gmail.com

unread,
Dec 14, 2014, 7:34:19 AM12/14/14
to j2objc-...@googlegroups.com
Commented out include to see what would happen see attached - is this the result of missing include or another problem?


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem6.pdf

Bruno

unread,
Dec 14, 2014, 1:00:24 PM12/14/14
to j2objc-...@googlegroups.com
Looking at your PDF, you tried the command "IS" instead of "LS" (converting to uppercase). This is one of the most common commands in all of Unix - see Wikipedia article.

For java/lang/process.h, I would've expected to find it in j2objc/include but it isn't there. I suspect it isn't there as it's something unsupported within iOS - see here. You'll have to remove this from your Java code to do the translation.

For the ARC errors, you'll need to disable Automatic-Reference-Counting as per the documentation.




--
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/d/optout.

Tom Ball

unread,
Dec 14, 2014, 2:41:58 PM12/14/14
to j2objc-...@googlegroups.com
And remove the --ignore-missing-imports flag -- it's going away tomorrow, as it's only purpose these days is to get people in trouble later.

mytc...@gmail.com

unread,
Dec 15, 2014, 7:57:52 AM12/15/14
to j2objc-...@googlegroups.com
Is "remove the --ignore-missing-imports flag" the cause of attached link problems or is it something else? 


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
BuildProblem7.pdf

Tom Ball

unread,
Dec 15, 2014, 10:15:23 AM12/15/14
to j2objc-...@googlegroups.com
The issue is that java.lang.Process is not supported by j2objc, since iOS apps can't fork processes due to its security sandbox. Because you used the --ignore-missing-imports flag, this issue wasn't reported when translating your Java sources, and instead became harder-to-understand link errors. 

That's why I'm removing the flag -- it was useful back when the JRE emulation was much less complete, but now it just confuses developers.

--

mytc...@gmail.com

unread,
Dec 16, 2014, 4:36:43 AM12/16/14
to j2objc-...@googlegroups.com

Does this mean I should look for a new release of J2objc to down load  or do I need to add a switch setting to

 

 

java -jar c:\j2objc\lib\j2objc.jar  MTCccActivity.java

 

If so what is the switch setting?

 


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:

Tom Ball

unread,
Dec 16, 2014, 10:31:53 AM12/16/14
to j2objc-...@googlegroups.com
I think you will have more luck with RoboVM, as it has better Eclipse integration. AFAIK, it also supports java.lang.Process, which was a missing dependency you reported.
 
--

mytc...@gmail.com

unread,
Dec 16, 2014, 12:28:41 PM12/16/14
to j2objc-...@googlegroups.com

I remove some Eclipse log java code which may have  created java.lang.Process. My application is simple java code that should be easier to translate. I did a re-translate and as you can see below there is no java.lang.Process. I am make to link errors. I would like to get this to work. J2objc I think is the best solution for me. Can we give it one more try? If you can show me how to set the switch I can re-translate and see what is causing  these link errors

BuildProblem8.pdf

Bruno

unread,
Dec 16, 2014, 1:17:16 PM12/16/14
to j2objc-...@googlegroups.com
Click on the error in the left hand column and copy and paste the command line that produced that error. Likely there's a problem in your linker flags.

--
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/d/optout.

Bruno

unread,
Dec 16, 2014, 1:17:34 PM12/16/14
to j2objc-...@googlegroups.com
It's a double click on the left hand column.

mytc...@gmail.com

unread,
Dec 16, 2014, 2:56:35 PM12/16/14
to j2objc-...@googlegroups.com
BuildProblem9.pdf

Bruno

unread,
Dec 16, 2014, 3:00:53 PM12/16/14
to j2objc-...@googlegroups.com
mytcoach - this'll be the last thing I try for you, beyond that it will just take too much time and we've all got other things we're too busy with. Create a public github repository and upload all the files to that. I'll download, fix the errors and send you the changes. If it takes more than 30 minutes to do that, then I'm sorry but I can't help any more.

On Tue, Dec 16, 2014 at 11:56 AM, <mytc...@gmail.com> wrote:


On Monday, December 8, 2014 3:44:43 PM UTC-6, mytc...@gmail.com wrote:
Down loaded and unzipped from https://github.com/google/j2objc. on mac. Did not appear to install anything as per instruction http://hemantasapkota.github.io/posts/j2objc-eclipse-plugin/. What am I doing wrong?

--
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/d/optout.

mytc...@gmail.com

unread,
Dec 16, 2014, 3:59:00 PM12/16/14
to j2objc-...@googlegroups.com
Thanks but let me try to find all these myself. Please just confirm that these are translate problems and nothing to do with link files. I think I can change the java source but I don't understand why it is having a problem with these statements and not others? Or am I not understanding the problem? Thanks again for your help - if my link parms are correct I think I can fix the errors

Bruno

unread,
Dec 16, 2014, 4:29:31 PM12/16/14
to j2objc-...@googlegroups.com
java.lang.process is entirely unsupported, so you'll need to remove that entirely BEFORE the translation

For the linker flag, there should be NO space after "-l", from the PDF, it looks like you have one:

YOU:     -l jre_emul
CORRECT: -ljre_emul

The other errors look like include or linking problems.


--
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/d/optout.

mytc...@gmail.com

unread,
Dec 16, 2014, 5:45:51 PM12/16/14
to j2objc-...@googlegroups.com
Thanks again - I can take it from here

mytc...@gmail.com

unread,
Jan 2, 2015, 6:58:35 AM1/2/15
to j2objc-...@googlegroups.com
I need to pass Strings from ViewController to the same instance of my Java code MTCccActivity. How can this be done without having to modify the J@OBJC generated object-c code?
I tried the following 

     MTCccActivity *theInstance = [[MTCccActivity alloc] init];
        [theInstance swipeU];
        
This is working  but I get a new instance every time.   
From what I have read IOS Delegates are the only anwser to my problem. This appears to require modifying generated object-c code.  Do you hve any suggestions?

Tom Ball

unread,
Jan 2, 2015, 11:27:03 AM1/2/15
to j2objc-...@googlegroups.com
Just save the singleton somewhere, like you'd do in any other code. Instances of translated Java classes don't need to be created inside of translated code, as it's all just Objective-C after translation. The MTCccActivity instance can be stored in the ViewController (just copy the above line into its Objective-C native code), or defined as a Java static variable. Here's an example in the j2objc-sample-reversi project, where an instance of the translated Othello.Engine.CommandInterface class is created in the app's ViewController.

--
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-discuss+unsubscribe@googlegroups.com.

mytc...@gmail.com

unread,
Jan 3, 2015, 1:50:50 PM1/3/15
to j2objc-...@googlegroups.com
Using your advice I made the changes below which solves my instance problem. I hope I correctly followed your instructions? See comments below
 Thanks for all the help. j2objc is a great resource.
Java Changes
public class MTCccActivity 
         {
// add
private static MTCccActivity instance = null;
  protected MTCccActivity() {
     // Exists only to defeat instantiation.
  }
  public static MTCccActivity getInstance() {
     if(instance == null) {
        instance = new MTCccActivity();
     }
     return instance;
  }
// add end

ViewController Changes
  MTCccActivity *theInstance = [MTCccActivity getInstance];

// abuve needs to be in each ViewController method that uses a MTCccActivity method
// such as swipeU - II could not find away to  setup *theInstance  as objective-c class 
// vatiable in didViewLoad, 
// must be re-created in each method?

        [theInstance swipeU];

Tom Ball

unread,
Jan 3, 2015, 2:46:47 PM1/3/15
to j2objc-...@googlegroups.com
Try this instead (no need to define "theInstance" variables): "[[MTCccActivity getInstance] swipeU];". Another option is to define a static method in MTCccActivity, and call "[MTCccActivity swipe]":

public static void swipe() {
  instance.swipeU();
}


--
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.
Reply all
Reply to author
Forward
0 new messages