This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin Cookbook and have Ken Kousen on-line!
See this thread for details.
Win a copy of Kotlin Cookbook this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Acceptable characters to pass to Main's varargs

 
Ranch Hand
Posts: 118
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
  • 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?
 
Saloon Keeper
Posts: 2896
370
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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: 118
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 2896
370
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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: 118
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
  • 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: 67036
255
  • Mark post as helpful
  • send pies
  • 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: 118
4
MySQL Database Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Do you pee on your compost? Does this tiny ad?
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!