Hey guys,
I am making a Java program where it runs on a library. This library classifies my program as a script. So basically, I am scripting.

Now I want to make various scripts, but I want them all to have the same layout so that I can have the same utilities in every single script. This would make it easier for me to produce more scripts and you know what I mean.

But how do I do it? Another thing is, any method in my Main class must be static. I cannot make any method's in an interface or abstract class static, so that is where my problem starts. Also, I cannot make new object of my main class. Are there any work arounds ? If you don't understand what Im trying to say. Ill give more information.

Thanks.

By "runs on a library" I'm assuming you mean it will be an executable jar file. But I don't know what you mean by classifying your program as a script. Are you planning on writing a program to read some text files that serve as scripts in some particular syntax?

Why do you say you can't make a new object of your main class? One typically does this by writing something like:

public Class Foo {
   public static void main(String[] args) {
      Foo fooInstance = new Foo();
      // invoke methods on fooInstance here
         fooInstance.doSomething();
    }

   void doSomething() {
      // code body here
   }
}

Perhaps I'm missing something here.

Yeah, I can't make the new instance or object using
Foo fooInstance = new Foo();

because then the information wouldn't match. The script's instance is actually created by a program that runs it.

because then the information wouldn't match.

Can you explain what you are doing and how you can use java code to solve your problem?

The use of the word script is confusing. Java is a compiled language. I think of scripts as being "executed" by an interpreter that reads the source and does something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.