• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is there any way to make this without static ?(this time i give up again)

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello expert people,
i am wondering if there is a way to make the class into non-static : i mean this "public static class CronTask implements org.quartz.Job" into "public class CronTask implements org.quartz.Job". If i try without static identifier then an exception will be thrown, "org.quartz.SchedulerException : Problem instantiating class 'backup_pro$CronTask'". I dont want to use static because if i use that, i should change all my instance method into class method.


 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you simply have to spend it a separate file, because there must be only one public class per file.
Alternatively make the class non-public. I don't know whether this is a real option.

Editing your posting and spending some blanks in the long lines will make it better readable (they allow line-breaks).
And using code-tags is much more fun, if you use indentation - preferably real tabs like everybody knows
And perhaps you rethink the benefits of import-statements.
(The lines aren't broken, as long as your long lines force a very wide page to be drawn.)

demo:

[ March 11, 2005: Message edited by: Stefan Wagner ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arifin -- we went through this a couple of weeks ago -- you're still trying to figure it out?

Stefan's rewriting won't help. The problem is that this framework wants to call newInstance() on the Class object, and it can't if the inner class is non-static, because at the bytecode level, a non-static inner class has no default constructor, only one that takes an outer-class instance.

You absolutely have to make CronTask a static inner class, or a top-level class; there's no way around that. But what you can do is try to think of some other way to make the instance of backup_pro available to the CronTask object after it's constructed. Can you store the backup_pro object in a static variable somewhere? Can CronTask simply create its own instance? I'm sure you can think of more alternatives. In any case, you have to let the framework do what it needs to do, and that means you have to provide a Task that has a default constructor at the bytecode level. Concentrate on figuring out how to work with that rather than against it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic