- 浏览: 2551260 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Build the iOS Things with J2Objc
1. Install the J2Objc
Get the latest file from here https://j2objc.googlecode.com/files/j2objc-0.7.zip.
Unzip and put in the tool directory. Link it to the work directory.
>cd /opt
>sudo ln -s /Users/carl/tool/j2objc-0.7 ./j2objc-0.7
>sudo ln -s ./j2objc-0.7 ./j2objc
Add that directory to the bash path
>vi ~/.profile
export PATH=/opt/j2objc:$PATH
>. ~/.profile
2. Try the Sample
Follow the document, try a JAVA class hello world.
public class Hello {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
Compile the Java source code
>javac Hello.java
I got the class file Hello.class
Run the java class file based on JVM
>java Hello
Translate the JAVA source code to Object-C
>j2objc Hello.java
translating Hello.java
Translated 1 file: 0 errors, 0 warnings
I got 2 files, Hello.m and Hello.m
Compile the Object C source codes
>j2objcc -c Hello.m
Then there is a Hello.o file then.
Generate the executable file
>j2objcc -o hello Hello.o
Then there is a executable file named hello
Try to run that
>./hello
2013-04-11 13:52:44.019 hello[41640:707] hello, world
3. How to make that work with Maven
<build>
...
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <id>gen-objc</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>./gen-objc.sh</executable> <arguments> <argument>${project.artifactId}</argument> </arguments> </configuration> </execution> </executions>
</plugin>
</build>
This make the execution of the shell script during the package phase
>mvn package
Here are the shell script gen-objc.sh
#!/bin/bash
# call this shell script with the project artifactId
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` artifactId"
exit
fi
ARTIFACT_ID=$1
J2OBJC_OUT_DIR=gen-objc
SRC=target/${ARTIFACT_ID}-*-sources.jar
J2OBJCFLAGS="--no-package-directories -use-arc --prefixes sdk-core-prefixes.properties"
# Set this to point to j2objc home
J2OBJC_DISTRIBUTION=/opt/j2objc
J2OBJC=${J2OBJC_DISTRIBUTION}/j2objc
if [ ! -e "$J2OBJC" ]; then
echo "***************************************************"
echo "***************************************************"
echo " ERROR ... ERROR ... "
echo " --> could not find ${J2OBJC} "
echo " please install before continuing..."
echo "***************************************************"
echo "***************************************************"
exit
fi
rm -rf ${J2OBJC_OUT_DIR}
${J2OBJC} -d ${J2OBJC_OUT_DIR} ${J2OBJCFLAGS} ${SRC};
cd ${J2OBJC_OUT_DIR}
rm I*.m
for y in `ls *`;
do
sed -f ../objc_post_processing.sed $y > temp; mv temp $y;
done
# this is the customer things, if you do not need that, that is fine
# Replace SxxError with NSError *
rm SxxError.h
cd ..
In the file, sdk-core-prefixes.properties, they are the packages I think.
com.sillycat.easyrestapi.core:
com.sillycat.easyrestapi.core.impl:
Something like that.
For the file objc_post_pressing.sed, that maybe just get rid of some lines in the source codes.
# 0. generic preprocessing .. remove comments..
s/\(\/\/.*Created by \).*/\1 Xxxxxxx Compiler/g
# 1. j2objc generates fooWithNSString:(NSString *)name; for Java method
# foo(String name). We want foo:(NSString *)name;
s/With.*:(/:(/g
# 2. Replace JavaUtilDate with NSDate
s/JavaUtilDate/NSDate/g
s_#import "java/util/Date.h"__g
s/@class NSDate;//g
# 3. Replace JavaUtilList with NSArray *
s/id<JavaUtilList>/NSArray */g
s_#import "java/util/List.h"__g
s/@protocol JavaUtilList;//g
# 4. Replace JavaUtilSet with NSSet *
s/id<JavaUtilSet>/NSSet */g
s_#import "java/util/Set.h"__g
s/@protocol JavaUtilSet;//g
# 5. Replace XxxxxError with NSError *
s/id<XxxxxError>/NSError */g
s/@protocol XxxxxError;//g
# 6. Remove JreEmulation
s/#import "JreEmulation.h"//g
# 7. Replace 'withXxx' with 'with'
s/withXxx/with/g
4. Eclipse Plugin
http://j2objc-updatesite.hsapkota.com.au/4.2
Choose the directory of the installation j2obc and select a output directory. It works.
References:
https://code.google.com/p/j2objc/
http://hsapkota.com.au/index.php/projects/20-j2objc-eclipse-plugin-howto
1. Install the J2Objc
Get the latest file from here https://j2objc.googlecode.com/files/j2objc-0.7.zip.
Unzip and put in the tool directory. Link it to the work directory.
>cd /opt
>sudo ln -s /Users/carl/tool/j2objc-0.7 ./j2objc-0.7
>sudo ln -s ./j2objc-0.7 ./j2objc
Add that directory to the bash path
>vi ~/.profile
export PATH=/opt/j2objc:$PATH
>. ~/.profile
2. Try the Sample
Follow the document, try a JAVA class hello world.
public class Hello {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
Compile the Java source code
>javac Hello.java
I got the class file Hello.class
Run the java class file based on JVM
>java Hello
Translate the JAVA source code to Object-C
>j2objc Hello.java
translating Hello.java
Translated 1 file: 0 errors, 0 warnings
I got 2 files, Hello.m and Hello.m
Compile the Object C source codes
>j2objcc -c Hello.m
Then there is a Hello.o file then.
Generate the executable file
>j2objcc -o hello Hello.o
Then there is a executable file named hello
Try to run that
>./hello
2013-04-11 13:52:44.019 hello[41640:707] hello, world
3. How to make that work with Maven
<build>
...
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <id>gen-objc</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>./gen-objc.sh</executable> <arguments> <argument>${project.artifactId}</argument> </arguments> </configuration> </execution> </executions>
</plugin>
</build>
This make the execution of the shell script during the package phase
>mvn package
Here are the shell script gen-objc.sh
#!/bin/bash
# call this shell script with the project artifactId
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` artifactId"
exit
fi
ARTIFACT_ID=$1
J2OBJC_OUT_DIR=gen-objc
SRC=target/${ARTIFACT_ID}-*-sources.jar
J2OBJCFLAGS="--no-package-directories -use-arc --prefixes sdk-core-prefixes.properties"
# Set this to point to j2objc home
J2OBJC_DISTRIBUTION=/opt/j2objc
J2OBJC=${J2OBJC_DISTRIBUTION}/j2objc
if [ ! -e "$J2OBJC" ]; then
echo "***************************************************"
echo "***************************************************"
echo " ERROR ... ERROR ... "
echo " --> could not find ${J2OBJC} "
echo " please install before continuing..."
echo "***************************************************"
echo "***************************************************"
exit
fi
rm -rf ${J2OBJC_OUT_DIR}
${J2OBJC} -d ${J2OBJC_OUT_DIR} ${J2OBJCFLAGS} ${SRC};
cd ${J2OBJC_OUT_DIR}
rm I*.m
for y in `ls *`;
do
sed -f ../objc_post_processing.sed $y > temp; mv temp $y;
done
# this is the customer things, if you do not need that, that is fine
# Replace SxxError with NSError *
rm SxxError.h
cd ..
In the file, sdk-core-prefixes.properties, they are the packages I think.
com.sillycat.easyrestapi.core:
com.sillycat.easyrestapi.core.impl:
Something like that.
For the file objc_post_pressing.sed, that maybe just get rid of some lines in the source codes.
# 0. generic preprocessing .. remove comments..
s/\(\/\/.*Created by \).*/\1 Xxxxxxx Compiler/g
# 1. j2objc generates fooWithNSString:(NSString *)name; for Java method
# foo(String name). We want foo:(NSString *)name;
s/With.*:(/:(/g
# 2. Replace JavaUtilDate with NSDate
s/JavaUtilDate/NSDate/g
s_#import "java/util/Date.h"__g
s/@class NSDate;//g
# 3. Replace JavaUtilList with NSArray *
s/id<JavaUtilList>/NSArray */g
s_#import "java/util/List.h"__g
s/@protocol JavaUtilList;//g
# 4. Replace JavaUtilSet with NSSet *
s/id<JavaUtilSet>/NSSet */g
s_#import "java/util/Set.h"__g
s/@protocol JavaUtilSet;//g
# 5. Replace XxxxxError with NSError *
s/id<XxxxxError>/NSError */g
s/@protocol XxxxxError;//g
# 6. Remove JreEmulation
s/#import "JreEmulation.h"//g
# 7. Replace 'withXxx' with 'with'
s/withXxx/with/g
4. Eclipse Plugin
http://j2objc-updatesite.hsapkota.com.au/4.2
Choose the directory of the installation j2obc and select a output directory. It works.
References:
https://code.google.com/p/j2objc/
http://hsapkota.com.au/index.php/projects/20-j2objc-eclipse-plugin-howto
发表评论
-
ionic UI(5)UI and Backend
2016-12-02 03:22 597ionic UI(5)UI and Backend 1 Pr ... -
Stanford Cource(2)Demo App Caculator
2014-06-24 01:29 903Stanford Cource(2)Demo App Ca ... -
Mono on MAC
2014-06-04 03:27 985Mono on MACJust fine the tool f ... -
IOS7 App Development Essentials(4)IPhone5, IPhone5s, IPhone5c
2014-04-11 03:59 990IOS7 App Development Essentia ... -
IOS7 App Development Essentials(3)NSUserDefaults
2014-04-11 02:58 1010IOS7 App Development Essentia ... -
IPhone and Location(2)Documents Region Monitoring and Region Sample
2013-10-18 05:10 1736IPhone and Location(2)Documents ... -
IPhone and Location(1)Documents User Location
2013-10-18 03:50 1310IPhone and Location(1)Documents ... -
Learn Objective C(6)Programming with Objective-C - Working with Blocks and Deali
2013-10-18 00:02 931Learn Objective C(6)Programming ... -
Learn Objective C(5)Programming with Objective-C - Working with Protocols and Va
2013-10-17 23:47 1002Learn Objective C(5)Programming ... -
Learn Objective C(4)Programming with Objective-C - Encapsulating Data and Custom
2013-10-17 23:23 938Learn Objective C(4)Programming ... -
Learn Objective C(3)Programming with Objective-C - Defining Classes, Working wit
2013-10-17 23:09 1019Learn Objective C(3)Programmi ... -
Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
2013-10-17 00:30 970Learn Objective C(2)Learn Obj ... -
Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3
2013-10-17 00:22 1116Learn Object C(1) Learn Objec ... -
APNS(4)Recall the Process and Learn Java APNS
2013-04-18 02:48 3476APNS(4)Recall the Process and L ... -
APNS(3)Write the Easy Client App
2013-01-15 07:23 1721APNS(3)Write the Easy Client Ap ... -
APNS(2)Try to Finish the first Example
2013-01-14 07:56 1545APNS(2)Try to Finish the first ... -
Stanford Cource(1)MVC and Object-C
2012-12-14 14:04 1325Stanford Cource(1)MVC and Objec ... -
Some VI Tips
2012-11-15 04:48 1097Some VI Tips Today, I need to c ... -
MAC Mini Setup
2012-09-25 18:45 1335MAC Mini Setup I am dealing wit ... -
Android Talker(1)MAC Environment
2012-09-01 00:16 1929Android Talker(1)MAC Environmen ...
相关推荐
赠送jar包:j2objc-annotations-1.3.jar; 赠送原API文档:j2objc-annotations-1.3-javadoc.jar; 赠送源代码:j2objc-annotations-1.3-sources.jar; 赠送Maven依赖信息文件:j2objc-annotations-1.3.pom; 包含...
赠送jar包:j2objc-annotations-1.1.jar; 赠送原API文档:j2objc-annotations-1.1-javadoc.jar; 赠送源代码:j2objc-annotations-1.1-sources.jar; 赠送Maven依赖信息文件:j2objc-annotations-1.1.pom; 包含...
如果无法运行 查看J2OBJC_HOME是否正确; 查看Build Phases中的JRE.framework是否引入 相关的博客 http://blog.csdn.net/coooliang/article/details/79346001
J2OBJC的出现解决了跨平台开发中的一个重要问题,尤其是在企业级应用中,许多公司已经积累了大量的Java代码,通过J2OBJC可以轻松地将这些代码引入到iOS项目中。 **J2OBJC的工作原理** J2OBJC的工作流程大致分为...
The type com.google.j2objc.annotations.ReflectionSupport$Level cannot be resolved. It is indirectly referenced from required .class files
赠送jar包:j2objc-annotations-1.1.jar; 赠送原API文档:j2objc-annotations-1.1-javadoc.jar; 赠送源代码:j2objc-annotations-1.1-sources.jar; 赠送Maven依赖信息文件:j2objc-annotations-1.1.pom; 包含...
J2ObjC是一款强大的开源工具,主要功能是将Java语言编写的代码转换为Objective-C代码,使得Java开发者能够在iOS平台上进行开发,无需完全掌握Objective-C语言。这个工具由Google开发并维护,版本号为0.5.6,它为跨...
javaweb/javaee 常用jar包,亲测可用,若需其他版本其他jar包请留言我看到后会上传分享
java运行依赖jar包
Gradle依赖:【***.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【***-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: 中文-英文对照文档,中英对照文档,java,jar包...
**标题解析:** "j2objcDemo" 是一个基于j2objc框架的示例项目,旨在展示如何在iOS环境中调用Java代码。 **j2objc介绍:** j2objc 是Google开发的一个开源工具,它允许Java开发者将Java代码转换为Objective-C,以便...
标题中的“WSDL2Objc下载工具”是一个专门为iOS开发者设计的实用程序,它的主要功能是自动生成Objective-C客户端代码,从而简化与Web服务的集成过程。这个工具可以解析WSDL文件,并生成对应的Objective-C类,使得...
【标题】"ios-cocos2d-objc实现的跑酷游戏.zip" 提供的是一个基于Cocos2D-Objective-C框架开发的iOS平台上的跑酷类游戏源代码。Cocos2D-Objective-C是Cocos2D游戏引擎的一个版本,专为iOS应用设计,它允许开发者使用...
这是一个示例,展示了如何在使用 J2ObjC 的 iOS 应用程序中使用黑白棋游戏引擎。 最初的游戏奥赛罗由 Mats Luthman 编写,可从 他的网站获得。Mats 将其设计为既可以用作 Swing 应用程序,也可以用作命令行应用程序...
标题:“j2objc:Java转成Objective-C的用于移植Android库到iOS” j2objc 是一个开源工具,由Google开发,它的主要目的是帮助开发者将Java代码转换为Objective-C,使得Android库能够顺利地在iOS平台上运行。这个...
**标题解析:**"j2objc-dagger"指的是一个项目,它关注的是如何利用J2ObjC工具对Dagger2这个依赖注入框架进行翻译,以便在iOS平台上进行测试或运行。这里的“测试翻译”可能意味着将Java代码转换为Objective-C,以...
J2objc入门套件入门工具包是使用入门的好方法。 它包括一个简单的演示,向您... 假设在Mac上, $ln -s /path_to/j2objc/dist/j2objc /usr/bin/j2bjc$ln -s /path_to/j2objc/dist/j2objcc /usr/bin/j2objcc 通过键入以下
`WSDL2Objc` 是一个非常实用的工具,它能够帮助开发者自动生成适用于iPhone端的Objective-C源代码,从而简化了在iOS应用中调用Web服务的过程。这一工具的核心功能在于,它能够解析WSDL(Web Services Description ...
J2ObjC Gradle插件使Java源代码成为iOS应用程序构建的一部分,因此您可以用Java编写应用程序的非UI代码(例如应用程序逻辑和数据模型),然后由Android应用程序(本机为Java)和iOS共享应用程序(使用J2ObjC)。...