Can not use .in domain name in package

209

Solution 1

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.

https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

So you could use in_.co.mydomain

Solution 2

oracle suggested that,

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. For example:

enter image description here

Share:
209
AbsoluteDev
Author by

AbsoluteDev

Updated on December 15, 2022

Comments

  • AbsoluteDev
    AbsoluteDev over 1 year

    I tried to search on stack overflow regarding the issue I am facing but did not find any satisfactory answer. So, please read my question first and suggest.

    I have a .co.in domain that I want to use to prepare packages. But as per new java conventions(?) the keyword 'in' can not be used at starting of package name. Hence, I am getting problems in building applications. I have problem in building android application with flutter due to package name format in.co.mydomain.myapp. The problem persists in JavaFX applications also where I am using hibernate ORM. When application is run in debug mode, I see HQL queries generated with fully qualified names of entity class resulting into in.co.mydomain.myapp.entities.Student, here also 'in' keyword is a reserved keyword of SQL queries hence it throws errors.

    I need expert advice in such a horrible situation I am facing.

    The whole thing works without any problem when I rename package to com.mydomain.myapp

    • Vinay Prajapati
      Vinay Prajapati over 4 years
      why don't you just go for commercial package name i.e. com...? It's good practice to match the package structure with domains but you can't always ensure compatibility.
    • AbsoluteDev
      AbsoluteDev over 4 years
      My concern is using a domain other than com should not keep my app away from building. I already have spent for next few years for a .in domain. So, can you please point me to the regulation that prevents me using .in in package name? Just reading headless errors is not at all satisfying btw.
  • AbsoluteDev
    AbsoluteDev over 4 years
    Thank you for pointing to that resource, actually it was covered in classroom basics and unfortunately I forgot it. But now I know. So, thanks again @radulfr
  • radulfr
    radulfr over 4 years
    No problem, glad I could help.