Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Unicode Variable names Devanagari

Tags:

java

unicode

I am trying to code a program where I am trying to provide the variable names in Devanagari Script of Sanskrit. EXample :

class फिल्म
{
    public static void main(String args[])
    {
        String गीत = "Songs";
        System.out.println(गीत);
    }
}

When I try to execute this Java code, then it gives me the error

javac program.java

Error

display.java:1: error: illegal character: \0
 ■c l a s s   + ?       2       M       .
             ^
display.java:2: error: illegal character: \0

^
display.java:3: error: illegal character: \0
 {
^
display.java:3: error: illegal character: \0
 {
  ^
display.java:4: error: illegal character: \0

^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

        ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                      ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                    ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                              ^
display.java:5: error: class, interface, or enum expected
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                                       ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                                        ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                                                      ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                                                                ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )

                                                                                  ^
display.java:5: error: illegal character: \0
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   a r g s [ ] )


^
display.java:6: error: illegal character: \0

^
display.java:7: error: illegal character: \0
         {
^
display.java:7: error: illegal character: \0
         {
        ^
display.java:7: error: illegal character: \0
         {
          ^
display.java:8: error: illegal character: \0

^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
        ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                              ^
display.java:9: error: illegal character: \23
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                               ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                         ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                           ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                             ^
display.java:9: error: class, interface, or enum expected
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                              ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                                           ^
display.java:9: error: illegal character: \0
                 S t r i n g   ↨        @       $         =   " S o n g s " ;
                                                                             ^
display.java:10: error: illegal character: \0

^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

        ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                ^
display.java:11: error: class, interface, or enum expected
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                             ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                              ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                      ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                                      ^
display.java:11: error: illegal character: \23
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                                       ^
display.java:11: error: class, interface, or enum expected
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                                                                ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                                                                 ^
display.java:11: error: illegal character: \0
                 S y s t e m . o u t . p r i n t l n ( ↨        @       $       ) ;

                                                                                   ^

display.java:12: error: illegal character: \0

^
display.java:13: error: illegal character: \0
         }
^
display.java:13: error: illegal character: \0
         }
        ^
display.java:13: error: class, interface, or enum expected
         }
         ^
display.java:13: error: illegal character: \0
         }
          ^
display.java:14: error: illegal character: \0

^
display.java:15: error: illegal character: \0
 }
^
display.java:15: error: illegal character: \0
 }
  ^
52 errors

How can i properly execute this code ?

like image 745
Harshit Avatar asked May 30 '15 06:05

Harshit


1 Answers

Save the file in Unicode encoding, and use

javac -encoding Unicode program.java

to compile it

like image 63
Sujith Avatar answered Sep 28 '22 13:09

Sujith