#1072 New to fantom...

DumbDude Mon 12 Apr 2010

Hi guys! I have a couple of questions about the whole operation of this language: 1) I cant compile anything. It always outputs the same error:

java.lang.NoClassDefFoundError: and Caused by:
java.lang.ClassNotFoundException: and
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
Could not find the main class: and.  Program will exit.
Exception in thread "main" 

In this particular example I tried to compile:

class Main
{

  static Void main()
  {
     echo"I'm A Goat."
  }

}

2) Can I create a .exe file from a .fan file?

BTW: been using FantomIDE 1.5.1 with the fantom 1.0.49...

Thanks!

brian Mon 12 Apr 2010

I don't think the FantomIDE is up-to-date quite yet.

To run your simple example file you can just do: "fan myexample.fan". Also you'll need some parens for your call to echo:

echo("I'm A Goat.")

If you want to compile a pod you can follow instructions here.

Please let us know if you need any help!

DumbDude Mon 12 Apr 2010

OK...let's do this again. Slowly. If I wont be using the Fantom IDE, what am I suppose to do? use the fantom shell? I dont quite get the building a pod thing, or compiling. as a whole. (sorry for being a bit slow... I've been using only Microsoft Visual Studio or Eclipse till now... =] )

brian Mon 12 Apr 2010

If you only comfortable using an IDE, then you might just want to wait until tcolar releases his next version.

However if you want be adventurous, its always worthwhile to learn the command line tools. Sounds like you are working on Windows, so you'll be using a DOS console. I like to keep a simple "init.bat" file that I run whenever I open a DOS console which puts fantom/bin into my path.

You can start off by getting a feel by running scripts with "fan.exe". Then once you progress beyond a single source file you can tackle pods.

Take a read thru the docTools pod which explains how to setup your DOS console, invoke scripts, and build pods.

tactics Mon 12 Apr 2010

@brian What about flux? Does that have any build tools yet? If so, that might be another option.

brian Mon 12 Apr 2010

@brian What about flux? Does that have any build tools yet? If so, that might be another option.

Flux will automatically compile the pod of the current source file using F9, but you still have to hand code your build.fan script.

DumbDude Tue 13 Apr 2010

First of all: thanks alot! I was able to do just about everyting I wanted. except... (ALERT! NUBE Q AHEAD!): How do I read user input?

katox Tue 13 Apr 2010

Like this

class Main
{
  static Void main()
  {
     console := Env.cur // defaults to console
     console.out.print("Input text: ").flush
     userInput := console.in.readLine
     console.out.printLine("Good job! You wrote: $userInput")
  }
}

see examples/sys/files.fan directory for more I/O stuff.

Login or Signup to reply.