• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Acceptable characters to pass to Main's varargs

 
Ranch Hand
Posts: 124
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody have a list of acceptable, or better yet, unacceptable characters that when passed to Main as arguments will create a syntax error when running a simple java program. So far, ( and ) cause a syntax error, but other brackets do not. I assume parenthesis denote a method, a constructor??? and can't be used as arguments in the array?

I'm just jamming everything I can into the simple program as arguments to see what makes the program fail. Also, since I have already compiled the program, is this syntax error a runtime error?
 
Marshal
Posts: 4792
600
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Blake Edward wrote:So far, ( and ) cause a syntax error, but other brackets do not.


What errors are you seeing?  Most likely any errors would be from the shell where you are launching the application, not the application itself.

For example (Linux):
 
Blake Edward
Ranch Hand
Posts: 124
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java Zoo new (zoo)
-bash: syntax error near unexpected token `('

is what I see. But it can just be one bracket, empty brackets, etc.

I'm using Terminal on a Mac.
 
Ron McLeod
Marshal
Posts: 4792
600
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That error is from the bash shell, not your Java application.  You will need to do whatever the shell requires so that it doesn't try parse and interpret your input - for example: enclose your input in single quotes, or escape specific character with a backslash:

 
Blake Edward
Ranch Hand
Posts: 124
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you... that is the correct answer and backslashes work. I need to spend more time with this terminal...
 
Marshal
Posts: 80612
467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are all sorts of tutorials about Linux/Unix command lines available, most of which assume Bash is the default shell in use. Here is a tutorial I found about special characters.
 
Blake Edward
Ranch Hand
Posts: 124
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic