[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

change java file to bean

Posted on 2004-03-23
6
Medium Priority
?
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

656 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