[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

change java file to bean

Posted on 2004-03-23
6
Medium Priority
?
315 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
ID: 10657953
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
ID: 10658210

So a bean can have a main method?
0
 

Author Comment

by:Ronayne
ID: 10658257
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 10658301
>>So a bean can have a main method?

Yes. It probably just would not be called
0
 

Author Comment

by:Ronayne
ID: 10658578

ok, ill try that, thx
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10658634
8-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 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