• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Please fix this code..............urgent......some minor errors in compiling

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Next time you post please keep in mind these suggestions:
1) UseRealWords: Plzzz is not a real word and can cause confusion.
2) UseCodeTags: It makes reading the code much easier
3) TellTheDetails: For example stack traces and real error messages - it makes it much easier to diagnose problems.

The problem is that you are defining static variables inside a method. You can't do that. The static variables must be class member variables (ones that aren't in methods).

edit: I added the code tags this time. Next time, please do it yourself...
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve forgot EaseUp.

Abhinav Arya, you're used to C or C++ programming, aren't you? In case you are, Java doesn't know static local variables, only static fields. As such, they must be moved outside the method.
 
Abhinav Arya
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey Steve Luke ,
Thanks for the reply but even after declaring the variables in class outside the method I get these errors:

SriramSMS.java:12: cannot find symbol
symbol : class OutputStream
location: class SriramSMS
static OutputStream outputStream;
^
SriramSMS.java:33: cannot find symbol
symbol : class CommDriver
location: class SriramSMS
CommDriver commdriver = (CommDriver)Class.forName(driverName).newInstance();

^
SriramSMS.java:33: cannot find symbol
symbol : class CommDriver
location: class SriramSMS
CommDriver commdriver = (CommDriver)Class.forName(driverName).newInstance();




Please help me out!!!



Actually this is a code which I want to use for sending sms in my web app.........
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to import these classes.

It might be worth your while taking some time to go through the Java tutorial - taking the time to understand how the language works before getting too far into coding is a good thing!
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic