-2

I am coding to download some data from google apps domain greenleaf-uae.com, but when i enter the command

import com.google.gdata.data.greenleaf-uae.generic.GenericEntry; 

it gives me an error that ";" is expected and points to the "-" character. Is there something I am doing wrong.

How can I solve this.

Regards, Arjun

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
Arjun Bhandari
  • 191
  • 1
  • 11
  • 2
    Use underscores `_` (ref. [package naming](http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html)) – blgt Dec 30 '14 at 12:00
  • does not work, now i get more errors that package does not exist – Arjun Bhandari Dec 30 '14 at 12:01
  • possible duplicate of [Hyphenated company name in Java packages](http://stackoverflow.com/questions/3678520/hyphenated-company-name-in-java-packages) – alain.janinm Dec 30 '14 at 12:04

3 Answers3

1

From Oracle Docs:

In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore.

See the examples here: http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

Baderous
  • 1,069
  • 1
  • 11
  • 32
1

A hyphen is not a valid character for a package name. From this link about naming packages:

In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore.

So name you package as com.google.gdata.data.greenleaf_uae.generic.GenericEntry, and make sure to change the corresponding folder name from greenleaf-uae to greenleaf_uae as well.

M A
  • 71,713
  • 13
  • 134
  • 174
0

If you want to create your own package names, just use a different character to make it valid. If you want to use an existing API you need to double check: as - is invalid there is most likely no API out there which uses that package.

Is this an external API shipped in a JAR file? Then open it and check it out. Based on the naming conventions I suspect you want to use the gdata-java-client, it has a package named:

import com.google.gdata.data.appsforyourdomain.generic;
eckes
  • 10,103
  • 1
  • 59
  • 71