简体   繁体   English

不要在Eclipse中运行android应用程序

[英]Don't run android application in eclipse

When I want to run my java code, I have this problem : 当我想运行我的Java代码时,出现以下问题:

Exeption in thread "main" java.lang.ArrayIndexOutOfBoundsException:0
     at com.ibm.icu.text.BreakDictionary.main(BreakDictionary.java:44)

i can't run my code... It's simple 我无法运行我的代码...很简单

public class main{
   public static void main(String[] args){
      System.out.print("Hi");
   }
}

WTF is com.ibm.icu.text.BreakDictionary ? WTF是com.ibm.icu.text.BreakDictionary吗?

Make sure of the class whose main you are running. 确保正在运行其主类的类。 I suspect you're not running your class. 我怀疑你没有运行 Your java command should look like this: 您的java命令应如下所示:

java -cp somepath com.mycompany.mypackage.MyClass

Better yet, use an IDE like eclipse that make it easy to run a class 更好的是,使用像eclipse这样的IDE可以轻松地运行类

Also, rename your class from main to MyClass - anything with a leading capital letter - it's good coding style 另外,将您的班级从main重命名为MyClass任何带有大写大写字母的名称-良好的编码风格

Exeption in thread "main" java.lang.ArrayIndexOutOfBoundsException:0
 at com.ibm.icu.text.BreakDictionary.main(BreakDictionary.java:44)

This exception says that you are running the main method in a class named BreakDictionary . 此异常表明您正在名为BreakDictionary的类中运行main方法。 In your sample code the class is called main . 在您的示例代码中,该类称为main

You can solve this in eclipse by right-clicking your class and select run as and then java application. 您可以通过右键单击您的类并选择run as,然后选择Java应用程序来解决此问题。 This will ensure that you are using your main class as the entry point and not BreakDictionary (which seems to either be on your classpath or you are simply not running the correct project in eclipse). 这将确保您将主类用作入口点,而不是BreakDictionary(它似乎在您的类路径上,或者根本就没有在Eclipse中运行正确的项目)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM