Solved

change java file to bean

Posted on 2004-03-23
6
294 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 86

Accepted Solution

by:
CEHJ earned 50 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

860 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