Solved

change java file to bean

Posted on 2004-03-23
6
290 Views
Last Modified: 2013-11-21
Hi Experts, if I have a java file that has a main method and executes on its own, what changes are needed to change it to a bean?
0
Comment
Question by:Ronayne
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
A java class cannot 'execute on its own' - if it's an application, it has to have its main method called. Turning it into a bean would really entail ensuring that it has an empty constructor and making sure it has private member variables with public accessor/mutator methods.

private int someVal;

public void setSomeVal(int someVal) {
      this.someVal = someVal;
}

public int getSomeVal() {
      return someVal;
}
0
 

Author Comment

by:Ronayne
Comment Utility

So a bean can have a main method?
0
 

Author Comment

by:Ronayne
Comment Utility
So if I have a java file declared like so:

import statements

public class sample {
  public static void main (String args[]) throws Exception {
 
  }
}

Do I need to make the changes you suggested?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
Comment Utility
>>So a bean can have a main method?

Yes. It probably just would not be called
0
 

Author Comment

by:Ronayne
Comment Utility

ok, ill try that, thx
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
8-)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now