Java创建.jar文件(Java creating .jar file)
我正在学Java,我有一个问题。 我创建了6个不同的类,每个都有自己的
main()
方法。 我想为每个类创建可执行文件.jar
,即6个可执行的.jar
文件。到目前为止我试过
java -jar cf myJar.jar myClass.class
我得到'无法访问jarfile cf' 。 我做错了事,但我不知道什么。 我也使用Eclipse IDE,如果这意味着什么。
I'm learning Java and I have a problem. I created 6 different classes, each has it's own
main()
method. I want to create executable.jar
for each class, that is 6 executable.jar
files.So far I tried
java -jar cf myJar.jar myClass.class
and I get 'Unable to access jarfile cf'. I'm doing something wrong but I don't know what. I'm also using Eclipse IDE if that means something.
原文:https://stackoverflow.com/questions/4597866
最满意答案
实际上你可以通过类型化来访问topViewController的属性。 例如,你的topViewController名称是“FirstViewController”,那么你可以这样做
FirstViewController *fvc = (FirstViewController*)self.navigationController.topViewController; [fvc.tableView setEditing: YES animated: YES];
我希望这能帮到您。
Actually you can access the property of topViewController by typecasting it. For example your topViewController name is "FirstViewController" then you can do this as
FirstViewController *fvc = (FirstViewController*)self.navigationController.topViewController; [fvc.tableView setEditing: YES animated: YES];
i hope this will help you.
相关问答
更多-
实际上你可以通过类型化来访问topViewController的属性。 例如,你的topViewController名称是“FirstViewController”,那么你可以这样做 FirstViewController *fvc = (FirstViewController*)self.navigationController.topViewController; [fvc.tableView setEditing: YES animated: YES]; 我希望这能帮到您。 Actually yo ...
-
如何在Objective-C类中使用可选块?(How to have optional blocks in an objective-c class? [duplicate])[2022-11-02]
你可以试试这个: if (self.onCloseBlock){ _onCloseBlock(); } You can try this: if (self.onCloseBlock){ _onCloseBlock(); } -
也许比较“类似c”的语言和obj-c会很有用 - 让我们一起去看看Java。 想象一下带有setBackgroundColor方法的Rectangle类。 我们假设我们有一个名为rect的Rectangle实例。 在Java中,方法签名可能会是 public void setBackgroundColor(int r, int g, int b) { ... } 在Objective-C中,参数是方法签名的一部分,所以它可能是 - (void)setBackgroundColorWithRed:(int) ...
-
从概念上讲,发生的情况是有一个调度程序库(通常称为Objective C运行时),编译器会转换如下内容: [myObject myMethodWithArg:a andArg:b ]; 成 //Not exactly correct, but close enough for this objc_msgSend(myObject, "myMethodWithArg:andArg:", a, b); 然后,运行时处理所有的绑定和分派,找到一个合适的函数,并用这些参数调用它。 简单地说,你可以认为它有点像散 ...
-
块是回调或委托的一个很好的替代方法,如果只是通过将业务逻辑保持在调用代码本地来提高代码可读性。 但它们还有很多:对异步性非常有用,如果你想用GCD来提高性能,这是必要的。 除了苹果官方文档,我强烈建议阅读Mike Ash的优秀实用块 。 Blocks are a nice alternative to callbacks or delegates, if for nothing else than improving code readability by keeping your business log ...
-
Objective-c中的几个错误(Several errors in Objective-c)[2022-05-21]
你错过了 #import "CalculatorBrain.h" 在.h文件的顶部。 You are missing #import "CalculatorBrain.h" at the top of your .h file. -
您可以使用performSelector:withObject: for (NSString *key in arrayOfKeys) { SEL aSelector = NSSelectorFromString(key); id anObject = [self performSelector:aSelector withObject:nil]; [aCoder encodeObject:anObject forKey:key]; } 这是在运行时动态调用方法的方法,只使用该方法的名称作为字 ...
-
嗯,“[类型]看起来很相似”在编程中并不算多。 你缺少的是块和函数指针是不同类型的东西。 函数指针几乎就是函数代码的第一条指令的地址。 块是一个对象。 该对象持有的数据是函数指针,但它也有其他数据。 除了作为对象的基本基础结构(例如isa指针)之外,块还可以从其定义站点捕获变量值。 您可以在Objective-C中使用函数指针。 如果希望两个接口直接兼容,只需使用CALCULATION_CALLBACK作为Objective-C方法中callback参数的类型。 或者,您可以将函数指针包装在一个块中,如下所 ...
-
链接错误与混合C ++ / C或C ++ / Objective-C程序通常是由于C ++名称修改。 确保所有适当的声明都附有extern "C" ,并且所有代码都在链接上达成一致。 也就是说,确保函数定义以及使用它的地方都可以看到extern "C"或extern "C++" 。 在你的特定情况下,看起来MyFunction()使用C ++连接进行编译,并且名称受到了损坏,但是你的myMethod Objective-C文件试图链接到未加密的名称。 这里是维基百科关于名称修改的文章的链接。 Link er ...
-
这些变量原样无用。 它们不存储在其他任何地方,并且在runloop结束时自动释放。 将您的块视为一个自包含的函数:它不会在其范围之外写入任何内容,也不会返回任何内容。 These variables are useless as-is. They're not stored anywhere else, and are autoreleased at the end of the runloop. Consider your block as a self-contained function: it do ...