首页 \ 问答 \ Java创建.jar文件(Java creating .jar file)

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
更新时间:2023-05-27 13:05

最满意答案

实际上你可以通过类型化来访问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 ...
  • 你可以试试这个: 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 ...
  • 你错过了 #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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)