Can not use .in domain name in package
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:
AbsoluteDev
Updated on December 15, 2022Comments
-
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 over 4 yearswhy 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 over 4 yearsMy 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 over 4 yearsThank 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 over 4 yearsNo problem, glad I could help.