0

HelloWorld.ceylon

import java.util { HashMap } //Error:(1, 8) ceylon: package not found in imported modules: java.util (define a module and add module import to its module descriptor)

void run() {
    print("test");

}

module.properties

module CeylonHelloWorld "1.0" {
    import java.base "8";
}

I get an exception in HelloWord.ceylon file

kandi
  • 1,098
  • 2
  • 12
  • 24
  • Do you actually have Java 8 installed? If so, are you sure you're running your IDE with Java 8? Have you tried `import java.base "7"`? – Renato Oct 23 '14 at 18:17
  • @Renato I have installed java 8, but I tried "import java.base "7"" – kandi Oct 24 '14 at 05:44

3 Answers3

1

When I try that code, I get:

Incorrect syntax: mismatched token CeylonHelloWorld expecting initial-lowercase identifier

In module.ceylon.

The name of a module is supposed to be of form foo.bar.baz (initial-lowercase identifiers separated by periods).

Gavin King
  • 3,182
  • 1
  • 13
  • 11
0

Like mentioned by Gavin you will have to use a legal module name, when I change your code to use the module name "java8test" I get the following output when compiling:

$ ceylon compile java8test
warning: It looks like you are using class files from a Java newer than 1.7.
  Everything should work well, but if not, let us know at https://github.com/ceylon/ceylon-compiler/issues.
  In the near future, the Ceylon compiler will be upgraded to handle Java 1.8.
./source/java8test/run.ceylon:1: warning: import is never used: 'HashMap'
import java.util { HashMap }
              ^
2 warnings
Note: Created module java8test/1.0.0

Which is all as expected.

Quintesse
  • 452
  • 2
  • 9
0

module.ceylon

module holaCeylon "1.0.0"{
    import java.base "7"; // versión 7  JDK
}

package.ceylon

shared package holaCeylon;

Now we go back to the run.ceylon file and import the java.util.HashMap Java library.

run.ceylon

import  java.util  { HashMap }

shared void run(){
   print("Importando librerias de Java en Ceylon"); 
   value romanos = HashMap<String,Integer>();
    romanos.put("I", 1);
    romanos.put("V", 5);
    romanos.put("X", 10);
    romanos.put("L", 50);
    romanos.put("C", 100);
    romanos.put("D", 500);
    romanos.put("M", 1000);
    print(romanos.values());
    print(romanos.keySet());
}

Output: salida

Code: http://codemonkeyjunior.blogspot.mx/2015/03/ceylon-interoperabilidad-con-java.html