Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java YAML Reader

843789Dec 4 2009 — edited Dec 4 2009
I have a java program written which has to read a configuration file written using YAML (config.yml)

I downloaded the yamlbeans-1.0.jar from http://yamlbeans.sourceforge.net/ which has the YamlReader class I am using in my java program. And I then copied the YamlReader.class file to the folder where I have my Testing.java program.

Please find my java and config.yml files below.

//JAVA FILE
class Testing
{
public static void main(String args[]) throws Exception
{
YamlReader reader = new YamlReader(new FileReader("config.yml"));
Object object = reader.read();
System.out.println(object);
Map map = (Map)object;
System.out.println(map.get("NAME"));
}
}


//YAML file

NAME: mail.foobar.net
EMAIL_ADDRESS: foo@bar.net
AGE: 15



when I try to compile the java file, I get the following error.

C:\Users\David\Desktop\webstat\Testing.java:11: cannot access YamlReader
bad class file: .\YamlReader.class
class file contains wrong class: net.sourceforge.yamlbeans.YamlReader
Please remove or make sure it appears in the correct subdirectory of the classpath.
YamlReader reader = new YamlReader(new FileReader("config.yml"));
^
1 error

Tool completed with exit code 1

Can some one please suggest me what has to be done to get YamlReader accessible in my program.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2010
Added on Dec 4 2009
4 comments
890 views