Just going through the sample Scala password on Scala website, however encountered an annoying error as soon as trying to operation it.

You are watching: Editor does not contain a main type

Here"s the code: http://www.scala-lang.org/node/45. On running it ~ above Eclipse, I gained this blog post "Editor does no contain a key type" that prevents it indigenous running.

Is over there anything I should do...i.e break that record into many files, or what?


*

In Eclipse, make sure you add your source folder in the project properties -> java construct path -> source. Otherwise, the main() role may no be included in her project.


*

I have this difficulty a lot through Eclipse and also Scala. It help if friend clean your workspace and rebuild your Project.

Sometimes Eclipse doesn"t recognize properly which records it has to recompile :(

Edit:The code runs well in Eclipse


*

*

*

You have to make certain that your .java records are in the .src folder in eclipse. I had actually the very same exact problem until I got it figured out.


Just make certain that the folder you occupational in is included to the developed path:

right-click her folder --> develop Path --> usage as resource Folder

and it should now uncover main therein.


I had actually the exact same problem. Ns tried all sorts that things. And I came to know that

My .java documents were no linked and they were not placed in the "src" folder.

Things ns did:

Project nature >> Java develop Path >> resource

Deleted the initial "src" folder which to be empty making use of "Remove" optionAdded the resource that had my source .java records using the "Add Folder" option

This resolved the error.


*** Just close and also reopen

*** your project in eclipse. Sometime there are affiliation problems. This addressed my problem


A fast solution:

First, exclude the package:Right click on the resource package >> construct Path >> Exclude

Then incorporate it back:Right click on the resource package >> construct Path >> Include


What you need to do is, create a Java Project, however make certain you put this paper in the package file of the project, otherwise you"ll encounter same error.

*


That password is valid. Have you tried come compile that by hand using scalac? Also, have actually you referred to as your document "addressbook", every lowercase, like the name of the object?

Also, I uncovered that Eclipse, for some reason, collection the main course to be ".addressbook" instead of "addressbook".


you should produce your paper by

selecting on best side friend will discover your paper name,

under that will uncover src folder your you ideal click choose -->class option

their your paper should be created


Make sure that your .java document is current either in the str package, or in some other package. If the java paper with the main duty is outside all packages, this error is thrown.


Have faced the comparable issue, resolved this through right clicking the main an approach in the outline view and run together Java application.


I just had this problem too. The equipment is come make sure eclipse developed the job as Java project. Just create a brand-new Java project and copy your class into the src folder (and import the eventual dependencies). This should fix the problem.


The exactly answer is: the Scala library requirements to prior to the JRE library in the buildpath.

Go to Java Buildpath > Order and also Export and move Scala library come the top


I had actually this problem with a Java task that ns imported from the file system (under Eclipse Helios). Here"s a hint: the src code didn"t it seems ~ to be compiled in ~ all, as no "bin" catalog showed up.

I had actually to develop a Java task from scratch (using the wizard), then to compare the .project records of the non-working and also working projects.

The project giving "Editor does no contain a key type" had this as the "buildSpec" in the .project file:

But the working project had this together the "buildSpec":

org.eclipse.jdt.core.javabuilder I duplicated this in, and the imported project worked.

I know my answer is because that Java, however the same could be the problem for her Scala project.


share
boost this prize
monitor
answer Mar 12 "14 in ~ 0:28
user2704136user2704136
2955 bronze badges
add a comment |
1
May it is in the record you have created is exterior the src(source) folder. Make the efforts to speak to the class object(from the file located in the src folder) indigenous the .java file outside the source folder results in the same error. Copy .java file to the resource folder, then develop it. The error will be gone.


share
enhance this price
follow
edited Mar 22 "14 in ~ 17:38
answer Mar 21 "14 in ~ 6:52
Vamsi TallapudiVamsi Tallapudi
2,40511 gold badge1111 silver- badges2222 bronze title
include a comment |
1
I had actually the same problem. I had actually the main class out of the src package, in various other folder. I move it in and correct folder and solved


share
improve this answer
monitor
answered Aug 5 "15 in ~ 16:08
jacruzjacruz
5644 bronze badges
add a comment |
1
run "eclipse -clean -refresh" indigenous command line. This addressed the problem for me once all other solutions failed.


re-publishing
boost this prize
follow
reply Feb 12 "16 in ~ 1:19
MikeGMikeG
1111 bronze argorial
include a comment |
1
This might be the worry with the Java construct path.Try listed below steps :

Go to task properties go to java build PathGo to resource tab and add project"s src folder

This need to resolve the issue.


share
boost this answer
follow
answered january 4 "17 at 14:09
AalekhGAalekhG
30133 silver- badges77 bronze title
add a comment |
1
If that is maven task please check the java file is developed under src/main/java

If you room not obtaining please change the JRE path and create the java documents in above folder structure


share
improve this answer
monitor
answer Apr 26 "17 at 13:06
ssomussomu
5977 bronze badges
include a comment |
0
For me, in Eclipse 3.6, this difficulty occurs once my main method is not public. I led to the problem by having actually a main an approach like this:

static void main(String<> args) The dubugger to be unable come detect this by itself. I am quite suprised Eclipse overlooked this.


share
improve this answer
follow
answer Jun 21 "11 in ~ 3:28
djangofandjangofan
26k5555 gold badges175175 silver badges265265 bronze title
add a comment |
0
In the worst situation - develop the project once again v all the imports from the beginning. In my instance none of the other alternatives worked. This kind of error hints that there is an error in the project settings. Ns once managed to fix it, yet once further advances were done, the error come back. Recreating everything from the start helped me understand and also optimize some links, and now i am i was sure it works correctly.


re-superstructure
enhance this price
monitor
answer Jun 20 "12 in ~ 8:19
SergiuSergiu
34533 silver badges88 bronze badges
include a comment |
0
Follow the below steps:

Backup all her .java records to some other locationdelete whole java projectCreate new java task by right click on root & click newrestore every the papers to new location no
share
enhance this answer
follow
edited Oct 29 "12 at 5:50
Unni Kris
2,97333 gold badges2727 silver- badges5757 bronze badges
answered january 23 "12 in ~ 15:57
mani KandanMani Kandan
111 bronze argorial
add a comment |
0
File >> import >> present Projects into Workspace >> pick Archive Filed >> Browse and also locate record >> Finish. If its currently imported some other way delete the and try it that way. Ns was having actually the same trouble until ns tried that.


re-publishing
improve this prize
monitor
reply Apr 4 "13 at 0:52
MikeMike
1
add a comment |
0
One more thing come check: make certain that her source paper contains the exactly package declaration equivalent to the subdirectory it"s in. The error discussed by the OP have the right to be seen when trying to run a "main type" asserted in a record in a subdirectory but lacking the package statement.


share
improve this answer
monitor
answer Nov 28 "13 at 22:45
Daniel AshtonDaniel Ashton
1,20888 silver- badges2222 bronze title
include a comment |
0
I have this problem too after ~ I adjusted the source folder. The equipment that operated for is just modifying the record and conserve it.


re-superstructure
improve this price
follow
reply Aug 24 "14 in ~ 10:32
HunsuHunsu
3,01566 yellow badges2626 silver- badges5858 bronze title
add a comment |
0
Try "Update Project". Once I go this, The operation as Java Application option appeared.


share
boost this price
follow
answer Oct 25 "15 at 20:56
George SanthoshGeorge Santhosh
11922 silver badges1313 bronze title
include a comment |
0
In my certain "Hello World" instance the cause for this problem was the fact, that my main() an approach was inside the Scala class.

I placed the main() technique under the Scala object and also the error disappeared.

That is because Scala thing in Java state is the entity with only static members and methods inside.

That is why Java"s public revolution void main() in Scala should be placed under object.

See more: What Is The Binary Equivalent Of The Decimal Number 232? ? Convert Decimal Number 232 In Binary

(Scala course may no contain static"s inside)


re-publishing
enhance this prize
monitor
answered january 28 "16 at 20:46
Vlad.BachurinVlad.Bachurin
1,2801414 silver- badges2222 bronze title
add a comment |
1
2 Next
Highly active question. Earn 10 call (not count the association bonus) in order come answer this question. The reputation requirement helps defend this question from spam and also non-answer activity.

Not the answer you're spring for? Browse various other questions tagged eclipse scala or questioning your very own question.


The Overflow Blog
Featured top top Meta
Linked
0
"Selection does no contain a main type" what to do
3
java - Editor does not contain a key type
1
"Selection does no contain a main Type" - Eclipse run Error
2
Editor does no contain main kind in Eclipse
2
Editor does not contain a main kind in Katalon studio
0
Editor does not contain a main type, even though that does
0
Eclipse problem - acquiring standalone record to operation in project
0
Eclipse not allowing me come compile
-3
Does no contain key type
0
Launch Error: Editor does not contain a key type
See an ext linked concerns
related
4
java.lang.NoSuchMethodError: main when beginning HelloWorld with Eclipse Scala plugin
7
just how do friend uninstall the Scala Eclipse plugin?
738
does a "Find in project..." feature exist in Eclipse IDE?
4
Editor does not contain main type
5
failure to created JLineReader (Scala REPL)
3
once are Scala Semicolons compelled
2
just how do ns map a vital in eclipse to operation the task run configuration?
0
unable to understand the rather if declare in scala code listed below
hot Network concerns an ext hot questions
concern feed
i ordered it to RSS
inquiry feed To i ordered it to this RSS feed, copy and also paste this URL into your RSS reader.


lang-scala
stack Overflow
commodities
firm
ridge Exchange Network
site design / logo design © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.9.24.40305


Stack Overflow works ideal with JavaScript permitted
*

your privacy

By clicking “Accept all cookies”, friend agree ridge Exchange can store cookie on your device and disclose info in accordance v our Cookie Policy.