Solved

HowTo nest standalone Java into a MVC package

Posted on 2011-03-10
3
319 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:jandersonwidener
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 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:jandersonwidener
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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 87
eclipse java  build path 6 43
eclipse shortcuts 9 45
difference of if loops 23 38
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 …
This is an explanation of a simple data model to help parse a JSON feed
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 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 …

930 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

16 Experts available now in Live!

Get 1:1 Help Now