Java里面出现这个Selection does not contain和include a main type怎

运行Java程序时 点击run 出现launch error 提示 说selection does not contain a main type
什么意思啊_百度知道
运行Java程序时 点击run 出现launch error 提示 说selection does not contain a main type
什么意思啊
这两个都有的
运行时出了点小问题,可能方法不对
怎么在定义一个字符串二维数组啊
是不是要把数组填满啊
提问者采纳
;初始化str[0][0]=&str[1][2]=&;c&&quot,String数组默认为 &a&str[1][0]=&str[0][1]=&;b&quot,不填的话;;f&初始化不必自己填满;少了main函数 定义二维数组String str[][]=new String [2][3];e&str[1][1]=&;d&str[0][2]=&
提问者评价
都很好,,谢谢啦
其他类似问题
java程序的相关知识
其他3条回答
没有写main函数。
没有程序的执行入口点 staitc void main(){}
嗯嗯,程序没有入口,要写main(){}函数定义字符串二维数组city(1)100个城市名char cityEl00][16];/*假定城市名不超过16个字符*/数组在初始化时候不一定要写满,看你自己的具体情况自己决定初始化填写多少个数据,没有填写的元素,系统自动赋值为0例如一个数组 int a[2][2]初始化 a[2][2]={1,1,2};那么数组a的最后一个元素a[1][1]的值为0。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Java中运行时出现selection dose not contain a main type?_百度知道
Java中运行时出现selection dose not contain a main type?
helloworld,100.java * this program display helloworld on the screen *&#47,75)).*,请大虾指明是怎么回事;;public class helloworld extends graphicsprogram{ public void run(){
add(new Glabel(&quot.*;import acm,运行时出现selection dose notimport acm.graphics,world&quot.program,应该怎么改才可以运行,在eclipse中输入这段代码后(
}}本人是JAVA菜鸟;* * File&#47.java已经添加在工程中)
提问者采纳
意思是当前选择不是主类型..这个类不是主类selection dose not contain a main type..,没有main方法..,直接在它上面运行当然会出错了
请问现在我这个程序可以运行吗?在什么地方运行?在eclipse里我要怎么修改才可以运行,主类怎么添加呢?
可以在这个类里添加一个main方法,main方法声明为:public static void main(String[] args) ;或者新建一个类,类接口下面有三个可选项,其中有一个是main方法声明的,勾上就是一个主类了
提问者评价
谢谢,问题解决了!随便问下,有求数字根的代码吗?如+2+9=19,1+9=10,1+0=1.直到为个位数。
其他类似问题
按默认排序
其他3条回答
在里面写main方法没有main方法不能运行这个的,实例化这个类就行了。你要想运行这段就重新写个Test类
没有main方法
从新配置一下环境变量
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Just going through the sample Scala code on Scala website, but encountered an annoying error when trying to run it.
Here's the code: . On running it on Eclipse, I got this message 'Editor does not contain a main type' that prevents it from running.
Is there anything I need to do...i.e break that file into multiple files, or what?
I have this prolbem a lot with Eclipse and Scala. It helps if you clean your workspace and rebuild your Project.
Some times Eclipse doesn't recognize correctly which files it has to recompile :(
The Code runs fine in Eclipse
1,80811416
In Eclipse, make sure you add your source folder in the project properties -> java build path -> source.
Otherwise, the main() function may not be included in your project.
3,98041728
You have to make sure that your .java files are in the .src folder in eclipse. I had the same exact problem until I got it figured out.
A simplier way is to close your project and reopen it !
Just make sure that the folder you work in is added to the built path:
right-click your folder, --> build Path --> Use as source Folder
and it should now find main therein
hope this helps
I had the same problem. I tried all sorts of things. And I came to know that
1.My .java files were not linked and they were not placed in the 'src' folder.
Things I did
1.Project properties >> Java Build Path >> Source
Deleted the original 'src' folder which was empty using 'Remove' option
Added the source that contained my source .java files using the 'Add Folder' option
This solved the error.
That code is valid. Have you tried to compile it by hand using scalac? Also, have you called your file "addressbook", all lowercase, like the name of the object?
Also, I found that Eclipse, for some reason, set the main class to be ".addressbook" instead of "addressbook".
178k45332521
What you should do is, create a Java Project, but make sure you put this file in the package file of that project, otherwise you'll encounter same error.
you should create your file by
selecting on right side you will find your file name,
under that will find src folder their you right click select -->class option
their your file should be created
53k9121142
I just had this problem too. The solution is to make sure eclipse created the project as Java project. Just create a new Java project and copy your class into the src folder (and import the eventual dependencies). This should fix the problem.
A quick solution:
First, exclude the package:
Right click on the source package >> Build Path >> Exclude
Then include it back:
Right click on the source package >> Build Path >> Include
The correct answer is: the Scala library needs to before the JRE library in the buildpath.
Go to Java Buildpath > Order and Export and move Scala library to the top
I had this problem with a Java project that I imported from the file system (under Eclipse Helios).
Here's a hint: the src code didn't seem to be compiled at all, as no "bin" directory showed up.
I had to create a Java project from scratch (using the wizard), then compare the .project files of the non-working and working projects.
The project giving "Editor does not contain a main type" had this as the "buildSpec" in the .project file:
&buildSpec&
&/buildSpec&
But the working project had this as the "buildSpec":
&buildSpec&
&buildCommand&
&name&org.eclipse.jdt.core.javabuilder&/name&
&arguments&
&/arguments&
&/buildCommand&
&/buildSpec&
I copied this in, and the imported project worked.
I know my answer is for Java, but the same might be the issue for your Scala project.
May be the file you have created is outside the src(source) folder. Trying to call the class object(from the file located in the src folder) from the .java file outside the source folder results in the same error. Copy .java file to the source folder, then build it. The error will be gone.
For me, in Eclipse 3.6,
this problem occurs when my main method is not public.
I caused the problem by having a main method like this:
static void main(String[] args)
The dubugger was unable to detect this by itself.
I am pretty suprised Eclipse overlooked this.
7,6352285143
In the worst case - create the project once again with all the imports from the beginning. In my case none of the other options worked. This type of error hints that there is an error in the project settings. I once managed to solve it, but once further developments were done, the error came back. Recreating everything from the beginning helped me understand and optimize some links, and now I am confident it works correctly.
Follow the below steps:
Backup all your .java files to some other location
delete entire java project
Create new java project by right click on root & click new
restore all the files to new location !!
1,66111335
File >> Import >> Existing Projects into Workspace >> Select Archive Filed >> Browse and locate file >> Finish. If its already imported some other way delete it and try it that way. I was having the same problem until i tried that.
One more thing to check: make sure that your source file contains the correct package declaration corresponding to the subdirectory it's in.
The error mentioned by the OP can be seen when trying to run a "main type" declared in a file in a subdirectory but missing the package statement.
Make sure that your .java file is present either in the str package, or in some other package. If the java file with the main function is outside all packages, this error is thrown.
I have this problem too after I changed the source folder. The solution that worked for is just editing the file and save it.
You can try to run the main function from the outline side bar of eclipse.
You need locate file .java in folder src (in Project Explorer of Eclipse) and then it run.
I have just add a file .java into project and it isn't in folder src, so I have a same error.
I put again it into src, then it was build.
53k9121142
eclipse shortcut keys... as I knew systemout + shift-space will automatically generate a System.out.println(), I have seen people doing this, I couldn't, what's wrong?
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Upcoming Events
Stack Overflow works best with JavaScript enabledPosted by Zen on 9 August 2011 & 45,457 visits
About the author:
Creator of zenverse.net. I blog about stuffs that I am interested in, from Web Design & Development to Wordpress themes and tips, SEO, Creative inspirations, Google, Programming, Mac OS and Android OS. I make
too. You can follow me on Twitter
or . I recommend
<a href="/home?status=How+to+Fix+%22Editor+does+not+contain+a+main+type%22+Error+in+Eclipse+-+
Thank you. In Eclipse I had copied some old files into a new project, but until I read your explanation, I had not realized that I had not copied the .java files INTO the src folder. They were under it, but not in it.
Thanks for a very clear explanation of what I was doing wrong.
But still i am getting the same error. Can u pls help me to fix this error.
That worked for me. It was driving me buts because I copied a small program that worked in order to play around with some changes.
Ye effings gods, I have NO problem with hideously complex programs but I freaking HATE bureocracy. Why in the effing ell con&#8217;t someone design an environment with simple to understand bureocracy? Why the effing ell would someone create an environment so that when you created a project from scratch you would have to change file locations manually.
Effing ell.
I am in tears of joy. Nowhere could I find the solution. Thousands of shit posts on forums and no joy. Thank you so much. I love you.
Great! Step 2 rly worked 4 me. Thanks!
Leave a Reply
You must be
to post a comment.
Previous Post
Hey there, welcome to ZenVerse Blog!
I blog about stuffs that I am interested in, from Web Design & Development to WordPress Themes & Tips, SEO, Creative Inspirations, Google, Mac OS and Android OS.
While my online working environment is focused mainly on Wordpress, I make ,
and . Besides, I give out
to the readers.
Spread The Love
Subscribe to Our RSS feed
& Subscribe to
& Subscribe to
Bookmark This Page
Categories
: Mantap , Luar Biasa (Indonesia word for extra ordinary :)
: Sorry, our site has been hacked. We are fixing our site....
: Sorry bro.. But it seems none of the download links are work...
: I am unable to download this theme. The download link is bro...
: That worked for me as well.
Thanks much.
I was going to st...
: Thanks! I really appreciate the code. I was trying to figure...
: Thank you for sharing your expertise....
: i've been trying to delete some undeletable files FOREVER an...
: I just love checking out your writing, you have the greatest...
: I tried doing this and my problem about this is that the fil...
Recent Posts
Check this out
SWAGCT is a society of interesting, funny and cool content. Like us on Facebook!1168人阅读
检查自己主函数&& main 有没有,写得是否正确、
eclipse selection does not contain a main type
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:235689次
积分:3127
积分:3127
排名:第4718名
原创:75篇
转载:98篇
评论:45条
(1)(2)(1)(2)(7)(1)(1)(3)(3)(1)(4)(10)(2)(3)(5)(8)(7)(5)(21)(74)(7)(2)(3)}

我要回帖

更多关于 contain和include 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信