aspose file tools*
The moose likes Java in General and the fly likes is there any way to make this without static ?(this time i give up again) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "is there any way to make this without static ?(this time i give up again)" Watch "is there any way to make this without static ?(this time i give up again)" New topic
Author

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

benny rusli
Ranch Hand

Joined: Jan 15, 2005
Posts: 72
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.


Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

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 ]

http://home.arcor.de/hirnstrom/bewerbung
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is there any way to make this without static ?(this time i give up again)