Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HowTo nest standalone Java into a MVC package

Posted on 2011-03-10
3
Medium Priority
?
337 Views
Last Modified: 2013-11-13
Hey experts....
this question should be simpler than I think Im confused with...

If I have a test class that begins with the following code, how can I re-engineer this code to not start by itself but to be packaged into a larger MVC Project and be made available to be called directly by other classes within the package...


I just reconfigure the provided code by the vendor to become a constructor (with the neccessary argument parameters) right ?...


thx Im just still trying to get better at Java... Not a master at churning code (yet) ...
// starts with this public statement
  public static void main(String argv[]) {
    if ( argv == null || argv.length != 3 ) {
      System.err.println("usage: TestConnect <ccapi URL> <campusId> <shared key>");
      System.exit(1);
    }

Open in new window

0
Comment
Question by:JAaron Anderson
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 35099573
if you want to call the main from another class you would use

MyClass.main(new String[] { ccapiUrlString, campusId, SharedKey });
0
 

Author Comment

by:JAaron Anderson
ID: 35100162
I already have a " main " function in my ViewDefinition class that returns the index.jsp page for the main portion of the beginning webpage...

Im triggering the newly incorporating class into my MVC environment to execute new methods when other methods are triggering...

e.g. when user hits submit on form I am taking that field info from JSP page and pushing it through this new Class to update a service on a remote server...


I think this code is all I have to do make this class available to any/all other classes  of the same package... Ill try compiling and see what happens...
private static final long campusId = 123;
  private static final String urlStr = "https://my.url.API.location.tld";
  private static final String sharedKey = "32fhb9p2348qhq234f";
  public String ccUID;
  public String ccEXP;
	
// jaa Constructor method for initialization by other classes

NewClassAPIManager( ccUsername, ccExpiration ) {
		this.urlStr = urlStr;
		this.campusId = campusId; 
		this.sharedKey = sharedKey;
		this.ccUID = ccUsername;
		this.ccEXP = ccExpiration;	
	}

Open in new window

0
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 35100253
yes all you need to do is make it available
forget about the main, it is only used/needed to run the class
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

971 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