Help - Editor does not contain a main type error (Eclipse)
Hello,
I'm trying to run a Text input program out of the Eclipse program and I keep getting this Editor does not contain a main type error - can someone help me
here's the code
import java.io.File;
import java.io.FileNotFoundException;
import java.text.DecimalFormat;
import java.util.Scanner;
import uwcse.io.Input;
public class FileInputExample {
public static void main(String[] args) {
// Create a Scanner to read the input file
String fileName = new Input().readString("Input file name? ");
System.out.println();
Scanner scan;
try {
scan = new Scanner(new File(fileName));
} catch (FileNotFoundException e) {
System.out.println(fileName + " doesn't exist!");
return;
// Read the file and count the number of occurences of A, B, ...
int[] count = new int[26];
while (scan.hasNextLine()) {
String line = scan.nextLine();
line = line.toLowerCase();
for (int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if (c >= 'a' && c <= 'z') {
count[c - 'a']++;
scan.close();
int length = 0;
for (int i = 0; i < count.length; i++) {
length += count;
// Display the statistics (as an histogram)
DecimalFormat df = new DecimalFormat("0.00");
for (int i = 0; i < count.length && length > 0; i++) {
double percent = count[i] * 100.0 / length;
String display = "" + (char) ('a' + i);
display += "(" + df.format(percent) + "%):\t";
for (int j = 1; j <= Math.round(percent); j++) {
display += "X";
System.out.println(display);
}Thanks
First, note that your program uses a non-standard class, "uwcse.io.Input" which is not available to us. Normally that is a show stopper - in this case, it's not, as I was able to eliminate its use.
Your program runs fine, so the error is an Eclipse error unrelated to Java.
You need to ask for help at an Eclipse support site, not here, as these forums are Java language forums.
Similar Messages
-
[Eclipse Problem] Selection does not contain a main type?
well i am using a GUI builder software which generates java code, i made a simple one to test and it will not compile.
import java.awt.*;
import javax.swing.*;
public class name {
@SuppressWarnings("unused")
private void initComponents() {
panel1 = new JPanel();
label1 = new JLabel();
textField1 = new JTextField();
panel1.setLayout(new FlowLayout());
label1.setText("Name:");
label1.setHorizontalAlignment(SwingConstants.LEFT);
panel1.add(label1);
textField1.setColumns(12);
textField1.setText("hi");
panel1.add(textField1);
private JPanel panel1;
private JLabel label1;
private JTextField textField1;
}it should make a basic swing GUI but it just gives me the error "Selection does not contain a main type"
I did not select in eclipse "use public static void main" i know im not supposed to because this has no main method, but how am i to compile this? =X
Edited by: -Johnny- on May 14, 2008 6:44 PM
Edited by: -Johnny- on May 14, 2008 6:44 PM-Johnny- wrote:
ya i used javac instead of eclipse then running it complains like you say
but is there any way to compile this code and it will work? I was hoping to use this GUI builder for business purposes but it seems like a waste of money so far if i can't make working java application with it =\The code is fine. You need to learn the basics. Start with the intro tutorials at the Sun type and start reading and coding.
Here is what the rest could look like:
import java.awt.*;
import javax.swing.*;
public class name
@SuppressWarnings("unused")
private void initComponents()
panel1 = new JPanel();
label1 = new JLabel();
textField1 = new JTextField();
panel1.setLayout(new FlowLayout());
label1.setText("Name:");
label1.setHorizontalAlignment(SwingConstants.LEFT);
panel1.add(label1);
textField1.setColumns(12);
textField1.setText("hi");
panel1.add(textField1);
private JPanel panel1;
private JLabel label1;
private JTextField textField1;
public name()
initComponents();
public JPanel getPanel()
return panel1;
private static void createAndShowUI()
JFrame frame = new JFrame("name");
frame.getContentPane().add(new name().getPanel());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args)
java.awt.EventQueue.invokeLater(new Runnable()
public void run()
createAndShowUI();
}Edited by: Encephalopathic on May 14, 2008 7:10 PM -
Error: Batch does not contain a valuation type
Hi,
When I'm trying to do MB1B for the below parameters, I'm getting the error:
Transaction MB1B
movement type 411
special stock Q
plant XXXX
storage location YYYY
WBS element a12334455674787698
material 1234
quantity n
batch 12345678
'Batch 'material no' 'plant' 'batch no' does not contain a valuation type. Message no. M7 045
But the batch has a valuation type and the material is assigned a valuation type too.
Can you please giude me to find out why is this behaviour?
Regards
JagHI, I've encounter the same problem. But I used the movement type 323 E.
I input the data as below:
material 2000000564
plant S010
storage location 2001
batch 0903011208,
and got the message M7045 saying that Batch 2000000564 S010 0903011208 does not contain a valuation type, but the batch 0903011208 do have a valuation type in it!
When I use movement type 323, there isnt' any error message returned!
so, I guess there is a bug in the program! -
Batch 30008068 6110 0000012614 does not contain a valuation type
Hi,
I am trying to issue a material from a very old batch but it is s giving a following error message.
BATCH does not contain avaluation type.
I want to remove a stock from the batch.
How can we remove.
Regards,
SAGARHi,
Please check for the Account Determination process for valuation class 6110. and GL account. Check entire process once.
Also, as u r saying old batch, check material master record with batch managment status and batch managment active in customizing.
While goods issue, enter batch number....
Hope this will help.
Regards,
Smitha -
Hi,
Need help solving a Task that returns a Task<IEnumerable<Writing>> so I can fill ObservableCollection<ViewModels.IWritingItemViewModel> Writings for my
Design Time Data Page:
<d:Page.DataContext>
<designTimeData:MainPageViewModel />
</d:Page.DataContext>
My constructor does this:
public MainPageViewModel()
var writings = this.GetGroupsAsync();
this.Writings = new ObservableCollection<ViewModels.IWritingItemViewModel>();
var viewmodels = writings.Select((x, i) => new WritingItemViewModel
Writing = x,
VariableItemSize = (i == 0) ? Common.VariableItemSizes.Writings : Common.VariableItemSizes.Normal,
My var writings = this.GetGroupsAsync(); is:
public async Task<IEnumerable<Writing>> GetGroupsAsync()
await this.GetMenuDataAsync();
return this.Groups;
which in turn gets data from:
private async Task GetMenuDataAsync()
Uri dataUri = new Uri("ms-appx:///DesignTimeData/MenuData.json");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
string jsonText = await FileIO.ReadTextAsync(file);
JsonObject jsonObject = JsonObject.Parse(jsonText);
JsonArray jsonArray = jsonObject["Groups"].GetArray();
foreach (JsonValue groupValue in jsonArray)
JsonObject groupObject = groupValue.GetObject();
Writing group = new Writing(
groupObject["UniqueId"].GetString(),
groupObject["IsHeaderInteractive"].GetBoolean(),
groupObject["ViewType"].GetString(),
groupObject["ModelType"].GetString(),
groupObject["Page"].GetString(),
groupObject["Title"].GetString(),
groupObject["Subtitle"].GetString(),
groupObject["ImagePath"].GetString(),
groupObject["Description"].GetString(),
groupObject["GroupId"].GetString()
foreach (JsonValue itemValue in groupObject["WritingMenus"].GetArray())
JsonObject itemObject = itemValue.GetObject();
group.WritingMenus.Add(new WritingMenu(
itemObject["UniqueId"].GetString(),
itemObject["Page"].GetString(),
itemObject["Title"].GetString(),
itemObject["Subtitle"].GetString(),
itemObject["ImagePath"].GetString(),
itemObject["Description"].GetString(),
itemObject["Content"].GetString(),
itemObject["WritingsId"].GetString(),
itemObject["GroupId"].GetString(),
Convert.ToInt32(itemObject["Item"].ValueType)
this.Groups.Add(group);
and I get this Error:
Error 5 'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<App1.DesignTimeData.Writing>>'
does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type
'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<App1.DesignTimeData.Writing>>'
could be found (are you missing a using directive or an assembly reference?)
I'm creating collections of:
public interface IWritingItemViewModel : Common.IVariableSizedItem
Models.Writing Writing { get; set; }
and my class for creating data is:
public class Writing
public Writing(
string uniqueId,
bool isHeaderInteractive,
string templateType,
string viewModelType,
string page,
string title,
string subtitle,
string imagePath,
string description,
string groupId
this.UniqueId = uniqueId;
this.IsHeaderInteractive = isHeaderInteractive;
this.TemplateType = templateType;
this.ViewModelType = viewModelType;
this.Page = page;
this.Title = title;
this.Subtitle = subtitle;
this.ImagePath = imagePath;
this.Description = description;
this.GroupId = groupId;
this.WritingMenus = new ObservableCollection<WritingMenu>();
public string UniqueId { get; private set; }
public bool IsHeaderInteractive { get; private set; }
public string TemplateType { get; private set; }
public string ViewModelType { get; private set; }
public string Page { get; private set; }
public string Title { get; private set; }
public string Subtitle { get; private set; }
public string ImagePath { get; private set; }
public string Description { get; private set; }
public string GroupId { get; private set; }
public virtual ObservableCollection<WritingMenu> WritingMenus { get; private set; }
How can I solve or successfully complete this code?
Thanks!...
Code is like a box of chocolates!...I looked into your error message again, I found something interesting:
Error 5
'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<App1.DesignTimeData.Writing>>'
does not contain a definition
for 'Select'
and no extension method
'Select' accepting a first argument of type
'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<App1.DesignTimeData.Writing>>'
could be found (are you missing a
using directive or an assembly reference?)
That means: Task does not contain the definition for Select. This was reasonable, Task does not inherit IEnumerable interface.
var viewmodels = writings.Select((x, i) => new WritingItemViewModel
Writing = x,
VariableItemSize = (i == 0) ? Common.VariableItemSizes.Writings : Common.VariableItemSizes.Normal,
public async Task<IEnumerable<Writing>> GetGroupsAsync()
You need get the IEnumerable<Writing> for Select use. See this for more information:
How to: Return a Value from a Task
--James
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
"The stylesheet does not contain a document element" error
Hi,
I'm using Hyperion Financial Management 11.1.1.3
I successfully created intercompany transactions but when I select the "auto match" to perform the matching process, the running task page ensure that the process is completed successfully. However, when I press "log" I found the following error:
Error Number:-2147467259
Error Description:The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
Error Source:msxml6.dll
Page On which Error Occurred:/hfm/Administration/ShowRunningTaskLog.asp
My environment is win server 2003 on a VM and EPM 11.1.1.3
Thank you and best regards,
Ahmed.Hi taku,
Yes I've solved my issue.
Firstly, make sure that the entities and accounts used in the Intercompany Transaction are allowed for ICP in the metadata file by setting the attribute "IsICP=Y" to yes.
Then, after you press the "Match" button, wait until the process finished and don't open the log. Just close the running task page, after the status showed that it is completed, and open the "process IC transactions" page again you will find the square sign becomes green which means that the transactions are matched.
I followed the following example on Oracle by Example [http://www.oracle.com/technetwork/middleware/financial-management/tutorials/mictrans-094190.html?ssSourceSiteId=otncn]
It's about "Managing Intercompany Transactions in Financial Management".
I wish you can solve your issue soon.
Best wishes,
Ahmed. -
Selection does not contain main type
Hi All,
I am getting the Launch error saying:
"Selection does not contain main type" while running the program in eclipse.
Is there any common aspects from where it is being generated?
Thanks in advance
regardslkarmacharya wrote:
eclipse launch error: "editor doesn't contain a main type"Hi,
Please don't resurrect old threads, and this isn't an eclipse forum. I'm locking this thread. Create a new one if you have a specific Java programming related problem.
Kaj -
Eclipse "selection does not contain main type" - but it does contain a main
Hi!
I'm having a strange thing happen to me when using the eclipse IDE in a macintosh envirnment.
I imported a project, complete with package, and all of my classes. and when I try to run my main class, it tells me "selection does not contain main type".
Which is entirely untrue, the class I am trying to run contains a public static void main(), does anyone know what's going on here?the class is quite large, I don't think that it is a problem with the class, because it runs fine on my windows based pc (also in eclipse)...
-
Eclipse problem selection does not contain main type
i m using eclipse3.3 and have set all the necessary paths in it
but when i run a simple java program just for displaying hello world but
the error comes
selection does not contain main typeYou must have a class with a main method.
The main method must be public, must be static, must return void, must have parameter String [], and is case sensitive (so does Java).
Put this into your class
public static void main(String args[]) {
}Let me know if it answers your question.
Best regards. -
Schema to be handled does not contain a definition of type Order
Hi,
I am getting the error 'Schema to be handled does not contain a definition of type Order'
when i tried to import an XSD to create a data type in Integration repository. I checked my XML with the XML SPY and it is vallid.
Am i missing something? How can i import an XSD to create a datatype.
Regards,
SharadhaHi,
Make sure the datatype name and the main element name in the external xsd is same.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="..." targetNamespace="....">
<xsd:complexType name="Activate">
Also check this link same problem
Schema to be handled does not contain a definition of type Activate
Error: Schema to be handled does not contain a defintion of type
Re: Calling Idoc structure in creating Data Type
Re: How to import XSD?
Please reward points if it helps
Thanks
Virkanth -
Hello experts,
I'm totally new to C#. I'm trying to modify existing code to automatically rename a file if exists. I found a solution online as follows:
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
while (allFiles.Contains(tempFileName ))
tempFileName = String.Format("{0} ({1})", fileName, count++);
output = Path.Combine(folderPath, tempFileName );
string fullPath=output + ".xml";
However, it gives the following compilation errors
for the Select and Contain methods respectively.:
'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found
(are you missing a using directive or an assembly reference?)
'System.Array' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'System.Array' could be
found (are you missing a using directive or an assembly reference?)
I googled on these errors, and people suggested to add using System.Linq;
I did, but the errors persist.
Any help and information is greatly appreciated.
P. S. Here are the using clauses I have:
using System;
using System.Data;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;Besides your issue with System.Core, you also have a problem with the logic of our code, particularly your variables. It is confusing what your variables represent. You have an infinite loop, so the last section of code is never reached. Take a look
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace consAppFileManipulation
class Program
static void Main(string[] args)
string fullPath = @"c:\temp\trace.log";
string folderPath = @"c:\temp\";
string fileName = "trace.log";
string output = "";
string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath);
string extension = Path.GetExtension(fullPath);
string path = Path.GetDirectoryName(fullPath);
string newFullPath = fullPath;
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
//THIS IS AN INFINITE LOOP
while (allFiles.Contains(fileNameOnly))
tempFileName = String.Format("{0} ({1})", fileName, count++);
//THIS CODE IS NEVER REACHED
output = Path.Combine(folderPath, tempFileName);
fullPath = output + ".xml";
//string fullPath = output + ".xml";
UML, then code -
Does not contain a static 'Main' method suitable for an entry point_
Hello
I want to to do a project with Entiity Framework . I add a project to my solution for my domain class and it's name is 'LinkModel.DomainClasses'. when I prees F5 there is an error like bellow.
Could You help me to solve this? thanks alot
..\Documents\Training\LinkCodeFirstLast\LinkCodeFirst\LinkCodeFirst\LinkModel.DomainClasses\obj\Debug\LinkModel.DomainClasses.exe'
does not contain a static 'Main' method suitable for an entry pointHi bkshn,
This error is caused by the missing "Main" method in your project. it is the entry point of your project.
If you want to create a EF project, you could follow the way in the aricle below.
https://msdn.microsoft.com/en-us/data/ee712907#codefirst
The Main method is like below.
class Program
static void Main(string[] args)
using (var db = new BloggingContext())
// Create and save a new Blog
Console.Write("Enter a name for a new Blog: ");
var name = Console.ReadLine();
var blog = new Blog { Name = name };
db.Blogs.Add(blog);
db.SaveChanges();
// Display all Blogs from the database
var query = from b in db.Blogs
orderby b.Name
select b;
Console.WriteLine("All blogs in the database:");
foreach (var item in query)
Console.WriteLine(item.Name);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
And you could start to learn the EF from the following MSDN blogs.
https://msdn.microsoft.com/en-us/data/ee712907
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Source2wsdd: ServiceGen does not contain a start method - help!
Hello all Weblogic Users!
I would greatly appreciate any help with this problem.
I am getting this error when I do my build on Linux.
[source2wsdd] source2wsdd: Doclet class weblogic.webservice.tools.ddgen.ServiceGen does not contain a start method.
Previously I was getting an error where the ServiceGen class could not be found. This was occuring both in Windows and Linux.
For Windows, this can be fixed in two ways. 1) Run setWLSEnv.cmd first (in weblogic81/server/bin. 2) (Unconfirmed but try it) Add the tools.jar, weblogic.jar, and webservices.jar to the ant runtimes lib in Eclipse (see preferences/ant/runtimes/global entries. - This will let you run the task inside Eclipse)
In Linux, I added the webloigc.jar and webservices.jar to the user's special ~/'.ant/lib directory (see ant documentation). This too fixed the problem of being unable to find the ServiceGen class. But now I am getting the error above. I am ripping my hair out trying to fix it.
Any help would be appreciated.
Thanks to all....Hi bkshn,
This error is caused by the missing "Main" method in your project. it is the entry point of your project.
If you want to create a EF project, you could follow the way in the aricle below.
https://msdn.microsoft.com/en-us/data/ee712907#codefirst
The Main method is like below.
class Program
static void Main(string[] args)
using (var db = new BloggingContext())
// Create and save a new Blog
Console.Write("Enter a name for a new Blog: ");
var name = Console.ReadLine();
var blog = new Blog { Name = name };
db.Blogs.Add(blog);
db.SaveChanges();
// Display all Blogs from the database
var query = from b in db.Blogs
orderby b.Name
select b;
Console.WriteLine("All blogs in the database:");
foreach (var item in query)
Console.WriteLine(item.Name);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
And you could start to learn the EF from the following MSDN blogs.
https://msdn.microsoft.com/en-us/data/ee712907
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Schema to be handled does not contain a definition of type Activate
I am trying to create a new datatype called Activate based on an xsd file and this is the message I get ...
"Schema to be handled does not contain a definition of type Activate"
Anyone have any ideas why I can't use any of my external definitions in my mapping??Hi Andrew,
There are errors in your XSD :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="envelope">
<xs:complexType>
<xs:sequence>
<xs:element ref="header"/>
<b><xs:element ref="body"/></b>
</xs:sequence>
<xs:attribute name="version" use="required" type="xs:NMTOKEN"/>
</xs:complexType>
</xs:element>
<xs:element name="header">
<xs:complexType>
<xs:sequence>
<xs:element ref="manifest"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<b><xs:element name="manifest"></b>
<xs:complexType>
<xs:sequence>
<b><xs:element ref="authentication"/></b>
<b><xs:element ref="taxonomy"/></b>
</xs:sequence>
</xs:complexType>
(1)There is no reference named <b>'body', 'authentication' and 'taxonomy'</b>
(2)It should be closed (either by <b><xs:element name="manifest"/></b> or <b></element></b> )
Hope this will help you.
Regards
Suraj -
Projectname.exe' does not contain a static 'Main' method suitable for an entry point .
Hi,
I'm developing a blog reader for windows 8 store app. It was perfectly worked before. But because of some miss behave my coding i get below error. No other errors there.
Error 1 Program 'c:\Users\.........\Desktop\Blog_Reader\Blog_Reader\obj\Release\intermediatexaml\Blog_Reader.exe' does not contain a static 'Main' method suitable for an entry point C:\Users\..........\Desktop\Blog_Reader\Blog_Reader\CSC
Blog_Reader
Please help me to figure this.
Thank You!Go to your App.Xaml and R-Click Go to Properties
Check whether the Build Action is ApplicationDefinition
If not change it to ApplicationDefinition. Clean the code (solution ) and Deploy..
Chears....
Maybe you are looking for
-
IPhone Mail, Contacts, Calendars iCloud and Macbook iTunes settings what a mess!
So I have been having some trouble with my iCloud settings and my iPhone lately and tried some changes and have discovered many more issues that make no sense to me. I have an iPhone and a Macbook Pro. Before I set the settings for each device sepa
-
Hi, Unfortunately my Laptop has died (which had my iTunes on it). I want to ensure my music on my iPhone 5 and my iPad Air are backed up. Also, I want to sort my music in the way I used to with iTunes. How can I do this with just these two devices, i
-
My iBook just shuts off when it is still partially charged. Help?
Hello, I have an 14" iBook G4, and have been having problems lately with the computer shutting off (going dead, and not into sleep mode) after it has been running on battery power for awhile. It usually shuts off when the battery is at around 45-60 p
-
Photo stream not working after ios7 update
after updating to ios7 new photos taken with my iPhone 4S are not streaming automatically. my photo stream is activated in settings on all devices.
-
How can i log two (almost equal) data streams into one spreadsheet file?
Hello, My problem is (as stated above) that i would like to log data obtained from 15 current-sensors and data obtained from 15 pressure sensors into one spreadsheet file. The idea is to put them next to eachother (preferabley pressure current sensor