2010-08-15 12 views
8

मैं निम्नलिखित रॉकेट शुभारंभ एप्लिकेशन चलाने का प्रयास कर रहा हूँ:एक जावा अनुप्रयोग के रूप में एक स्काला एप्लिकेशन चल रहा है

object HelloWorld { 
    def main(args: Array[String]) { 
     println("Hello World!") 
    } 
} 
सीधे जावा से इस तरह

:

java -cp scala-library.jar HelloWorld 

(स्पष्ट रूप से स्केला साथ compliling के बाद)

लेकिन निम्न त्रुटि मिलती है:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld 
Caused by: java.lang.ClassNotFoundException: HelloWorld 
     at java.net.URLClassLoader$1.run(Unknown Source) 
(...) 
Could not find the main class: HelloWorld. Program will exit. 

क्या मैंने कुछ भी मामूली निगरानी की है जिसे मुझे इसे काम करने के लिए करने की ज़रूरत है?

+0

देखो: http://en.wikipedia.org/wiki/Scala_%28programming_language%29, मैं स्केला सही वर्ग पथ सेट उम्मीद है कि जावा का उपयोग करने से याद आ रही है। –

उत्तर

12

Java documentation से:

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

अपने classpath काम करना चाहिए की शुरुआत करने के लिए .: (या Windows पर .;) जोड़ना।

+0

धन्यवाद, मुझे यकीन था कि यह कुछ मामूली था। :) –

0

प्रयास करें: यहाँ

java -cp %SCALA_HOME%\lib\scala-library.jar;. HelloWorld

+0

क्या आप वाकई विंडोज का उपयोग कर रहे हैं? –

संबंधित मुद्दे