haxe代码非常简单:
Main.hx
package nekotest;
class Main {
public static function main() {
var name = neko.System.args()[0];
trace("Hello " + name);
trace("Your name is " + Std.string(name.length) + " characters longs.");
}
}
Run Code Online (Sandbox Code Playgroud)
在控制台中:
E:\WORKSPACE\HaxeTest\src>haxe -main nekotest.Main -neko test.n
nekotest/Main.hx:6: characters 19-35 : Unknown identifier : neko
Run Code Online (Sandbox Code Playgroud)
haxe和neko都已安装:
E:\WORKSPACE\HaxeTest\src>haxe
Haxe Compiler 2.10 - (c)2005-2012 Motion-Twin
Usage : haxe.exe -main <class> [-swf|-js|-neko|-php|-cpp|-cs|-java|-as3] <output> [options]
Options :
-cp <path> : add a directory to find source files
-js <file> : compile code to JavaScript file
-swf <file> : compile code to Flash SWF file
E:\WORKSPACE\HaxeTest\src>neko
NekoVM 1.8.2 (c)2005-2011 Motion-Twin
Usage : neko <file>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我使用的文件已经过时,"neko.System"已被删除.我使用新代码,可以编译:
static function main() {
Sys.println("What's your name?");
var input = Sys.stdin().readLine();
Sys.println("Hello " + input);
}
Run Code Online (Sandbox Code Playgroud)