By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

"Selection does not contain a main type" error help me out to resolve the issue

P: 1
Hi,
I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type".
The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop up as "selection does not contain a main type"

Please help me out in resolving the above issue to run the .java file.
I am facing same issue with other .java files inside the project
The code is as shown below:
Expand|Select|Wrap|Line Numbers
  1. package com.trilogy.dealerportal.web.component.dealer;
  2.  
  3. import com.trilogy.dealerportal.domain.Disposition;
  4. import com.trilogy.dealerportal.domain.ScoredLead;
  5. import com.trilogy.dealerportal.domain.ScoreCategory;
  6. import com.trilogy.dealerportal.security.AuthenticationService;
  7. import com.trilogy.dealerportal.service.DealerService;
  8. import com.trilogy.dealerportal.service.ScoreCategoryService;
  9. import org.apache.tapestry.BaseComponent;
  10. import org.apache.tapestry.IRequestCycle;
  11. import org.apache.tapestry.annotations.ComponentClass;
  12. import org.apache.tapestry.annotations.EventListener;
  13. import org.apache.tapestry.annotations.InjectObject;
  14. import org.apache.tapestry.annotations.Parameter;
  15. import org.apache.tapestry.components.IPrimaryKeyConverter;
  16. import org.apache.tapestry.event.BrowserEvent;
  17. import org.apache.tapestry.form.IPropertySelectionModel;
  18. import org.apache.tapestry.form.StringPropertySelectionModel;
  19. import org.json.JSONException;
  20. import org.json.JSONObject;
  21.  
  22. import java.text.DateFormat;
  23. import java.text.DecimalFormat;
  24. import java.text.Format;
  25. import java.util.ArrayList;
  26. import java.util.Collections;
  27. import java.util.Comparator;
  28. import java.util.List;
  29. import java.util.Map;
  30.  
  31. /**
  32.  * Scored lead summary component
  33.  *
  34.  * @author SoftServe
  35.  */
  36. @ComponentClass(allowBody = true, allowInformalParameters = false)
  37. public abstract class ScoredLeadSummary extends BaseComponent {
  38.     private static final IPropertySelectionModel DISPOSITION_MODEL;
  39.     private static final Format SCORE_FORMAT = new DecimalFormat("#");
  40.  
  41.     @InjectObject(value = "spring:dealerService")
  42.     public abstract DealerService getDealerService();
  43.  
  44.     @InjectObject("spring:authenticationService")
  45.     public abstract AuthenticationService getAuthenticationService();
  46.  
  47.     @Parameter(required = true)
  48.     public abstract DateFormat getDateFormat();
  49.  
  50.     @Parameter(required = true)
  51.     public abstract List<ScoredLead> getScoredLeads();
  52.  
  53.     @InjectObject("spring:scoreCategoryService")
  54.     public abstract ScoreCategoryService getScoreCategoryService();
  55.  
  56.     @Parameter(required = true)
  57.     public abstract int getItemsPerPage();
  58.  
  59.     @Parameter(required = true)
  60.     public abstract int getCurrentPage();
  61.  
  62.     public abstract ScoredLead getLead();
  63.     public abstract void setLead(ScoredLead lead);
  64.  
  65.     public abstract String getCurrent();
  66.     public abstract void setCurrent(String current);
  67.  
  68.     public abstract int getOrder();
  69.     public abstract void setOrder(int order);
  70.  
  71.  
  72.     private List<ScoredLead> scoredLeads = new ArrayList<ScoredLead>();
  73.  
  74.     static {
  75.         // initialize disposition model
  76.         Disposition dispositions[] = Disposition.values();
  77.         String strings[] = new String[dispositions.length];
  78.         for (int i = 0; i < dispositions.length; i++) {
  79.             strings[i] = dispositions[i].getDescription();
  80.         }
  81.         DISPOSITION_MODEL = new StringPropertySelectionModel(strings);
  82.     }
  83.  
  84.     public List<ScoredLead> getSortedLeads() {
  85.         int startIndex = getCurrentPage() * getItemsPerPage();
  86.         if (startIndex >= scoredLeads.size() - getItemsPerPage()) {
  87.             startIndex = scoredLeads.size() - getItemsPerPage();
  88.         }
  89.         if (startIndex < 0) {
  90.             startIndex = 0;
  91.         }
  92.         int endIndex = startIndex + getItemsPerPage();
  93.         if (endIndex > scoredLeads.size()) {
  94.             endIndex = scoredLeads.size();
  95.         }
  96.         if (getCurrent() != null) {
  97.             SortElement element = ((SortElement) getComponent(getCurrent()));
  98.             Comparator<Object> comparator = element.getComparator(getOrder());
  99.             if (comparator != null) {
  100.                 Collections.sort(scoredLeads, comparator);
  101.             }
  102.         }
  103.         return scoredLeads.subList(startIndex, endIndex);
  104.     }
  105.  
  106.     public boolean isCredit() {
  107.         return getDealerService().getDealerById(getAuthenticationService().getUserId()).getCredit();
  108.     }
  109.  
  110.     public Format getScoreFormat() {
  111.         return SCORE_FORMAT;
  112.     }
  113.  
  114.     public String getJson() throws JSONException {
  115.         ScoredLead lead = getLead();
  116.         ScoreCategoryService scoreCategoryService = getScoreCategoryService();
  117.         JSONObject json = new JSONObject();
  118.         json.append("firstName", lead.getFirstName());
  119.         json.append("lastName", lead.getLastName());
  120.         json.append("address", lead.getAddress());
  121.         json.append("zip", lead.getZip());
  122.         json.append("phone", lead.getPhone());
  123.         json.append("email", lead.getEmail());
  124.         json.append("year", lead.getYear());
  125.         // make sure this is compatible with {@link #SCORE_FORMAT}
  126.         ScoreCategory category = scoreCategoryService.getScoreCategoryByScore(Math.round(lead.getScore()));
  127.         json.append("score", category.getName());
  128.         json.append("make", lead.getMake());
  129.         json.append("model", lead.getModel());
  130.         json.append("autoFICO", lead.getAutoFICO());
  131.         json.append("house", lead.getHouse());
  132.         json.append("age", lead.getAge());
  133.         json.append("incomeRange", lead.getIncomeRange());
  134.         json.append("providerName", lead.getProviderName());
  135.         json.append("requestDate", lead.getRequestDate() != null ? getDateFormat().format(lead.getRequestDate()) : "");
  136.         json.append("autoLoans", lead.getAutoLoans());
  137.         json.append("autoLeases", lead.getAutoLeases());
  138.         json.append("scoreColor", category.getColor());
  139.         return json.toString();
  140.     }
  141.  
  142.     /**
  143.      * Get map string representation. Displays string which consists of two components - map size and maximum map value.
  144.      *
  145.      * @param map map of values. Usually either {@link com.trilogy.dealerportal.domain.Lead#autoLoans} or
  146.      * {@link com.trilogy.dealerportal.domain.Lead#autoLeases}
  147.      * @return map string representation. Returns null if map either empty or has no values which are not nulls
  148.      */
  149.     public String toString(Map<String, Integer> map) {
  150.         if (map == null || map.size() == 0) {
  151.             return "";
  152.         }
  153.         Integer maxValue = null;
  154.         for (Integer value: map.values()) {
  155.             maxValue = (maxValue == null || value != null && value > maxValue ? value : maxValue);
  156.         }
  157.         return map.size() + "-$" + (maxValue == null ? 0 : maxValue);
  158.     }
  159.  
  160.     public IPropertySelectionModel getDispositionModel() {
  161.         return DISPOSITION_MODEL;
  162.     }
  163.  
  164.     /**
  165.      * Credit infor change event listener. {@link #setDisposition(String)} does actual work
  166.      *
  167.      * @param event event
  168.      */
  169.     @EventListener(targets = "dispositionSelect", events = "onchange")
  170.     public void dispositionChange(BrowserEvent event) {
  171.         // do nothing here
  172.     }
  173.  
  174.     /**
  175.      * Converter method to convert <code>ScoredLead</code> into <code>long</code> and vice versa
  176.      *
  177.      * @return converter
  178.      */
  179.     public IPrimaryKeyConverter getConverter() {
  180.         return new IPrimaryKeyConverter() {
  181.             public Object getPrimaryKey(Object o) {
  182.                 return getScoredLeads().indexOf(o);
  183.             }
  184.  
  185.             public Object getValue(Object o) {
  186.                 return getScoredLeads().get((Integer) o);
  187.             }
  188.         };
  189.     }
  190.  
  191.     public String getDisposition() {
  192.         return getLead().getDisposition().getDescription();
  193.     }
  194.  
  195.     public void setDisposition(String disposition) {
  196.         // leads are read-only, at least for now
  197.     }
  198.  
  199.     public void sort(String id, int order) {
  200.         setCurrent(id);
  201.         setOrder(order);
  202.     }
  203.  
  204.     @Override
  205.     protected void cleanupAfterRender(IRequestCycle cycle) {
  206.         scoredLeads = null;
  207.         super.cleanupAfterRender(cycle);
  208.     }
  209.  
  210.     @Override
  211.     protected void prepareForRender(IRequestCycle cycle) {
  212.         scoredLeads = getScoredLeads();
  213.         super.prepareForRender(cycle);
  214.     }
  215. }
Sep 2 '08 #1
Share this Question
Share on Google+
1 Reply


Nepomuk
Expert 2.5K+
P: 3,112
Hi HarishAdea! Welcome to bytes.com!

It's great to have you here!

When you post, please always keep to the Posting Guidelines and when you post code, please post it in [code] ... [/code] tags (which, in this post, I have added for you).

About your problem:
Correct me if I'm wrong, but I can't see a main method (which you need) in that class. And if it isn't there, of course the JRE can't find it. I'm sure, you were planning for your code to start operating in a certain method - which one is it?

Otherwise, I'll just wish you the best and hope you enjoy being part of bytes.com!

Greetings,
Nepomuk (Moderator)
Sep 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.