NEWBE: can't run in GUI
I've seen other posts about this, but they seemed to be resloved by newer version. Ones which I'm already on.
Anyway: There doesn't seem to be a way to run my "hello world" app. I can only run a Scala console.
I'm running version 10.5 (build: #IU-107.105), and plugin version 0.4.1041 w/ scala version 2.9.0 on OSX. All of which were installed today.
I created a new probject. Scala is included as a facet. My code compiles, and I can run the .class files from the CLI.
But I can't seem to run it inside the GUI.
Any thoughts?
Please sign in to leave a comment.
Create an Application run configuration. Scala applications are the same as Java applications.
Try to run through context menu on your main object (right click, then choose "Run ..."). If it's impossible to do it, it's a bug. Then try to create run configuration manually.
Best regards,
Alexander Podkhalyuzin.
Same problem here :-(
I always read that IntelliJ has the best Scala support. But many people dont even get a simple Hello World application started. Neither do I...
I also read some other forum posts. I use a Mac, 10.5 Ultimate, Scala 2.9 plugin and can only run the Scala console, but not the application itself. I tried "extends app" and " def main(args: Array[String])". Both cannot be run. I also tried to use Run ... Edit configurations. I cannot click on "run" here. I tried for one hour to get this example working.
Can you please give a detailed explanation: How do I get this Hello World application started?
Thank you in advance!
Can you attach your sample project as an archive?
Sure. Here it is...
Attachment(s):
ScalaOne.zip
1) Change "Starter" from "class" to "object":
2) Invoke menu "Build"->"Rebuild Project"
3) While you have object Starter open, invoke "Right Mouse"->"Run Starter.main()" (or simply press Ctrl-Shift-F10)
4) See console output appear ;) (hopefully)
Kind regards,
-tt
Hi Jonathan,
Can you attach your sample project?
-tt
I also tried "object". I did again and rebuilt the project. Everything compiles successfully, but there is no "Run Starter.main"! Thus, the shortcut does not work either...
I again checked the Scala plugin. No error signal in the plugin manager.
Maybe you can upload an archive which is configured correctly - it must be a configuration problem ?!
Attached.
Note that I've added a project library that references my (local, 2.8.0) scala-compiler.jar and scala-library.jar.
You'll need to update it to point to your local versions.
In addition, I'm using a nightly build of the plugin.
Which version are you using? (you can find your version in the "Settings"->"Plugins" dialog)
-tt
Attachment(s):
ScalaOne.zip
Thanks. I imported your project, does not work. Will try it after work at home this evening again.
I use Scala plugin 0.4.1041.
I think I will de-install IntelliJ and all plugins and try from the beginning one more time. If I cannot make it running today, I will have to switch back to Eclipse again (although the Eclipse plugin is really not ready yet)...
Have you read this page http://confluence.jetbrains.net/display/SCA/Getting+Started+with+IntelliJ+IDEA+Scala+Plugin?
I'm not sure that all screenshots are up to date, but all steps should be the same.
Best regards,
Alexander Podkhlayuzin.
Yes, I did. I will try again from scratch this evening.
But as you can see in the comments, there are several guys which had exactly the same problem...
I hope to solve it tonight, wann do some real Scala coding with IntelliJ :-)
Ok, now I got one (of several) problems: My IDE uses Java 6, but it seems that I need Java 5, right?
I changed all links I found to Java 5 instead of Java 6. Now a "Run xyz.main" appears. If I run it:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java -Didea.launcher.port=7534 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10.app/bin -Dfile.encoding=UTF-8 -classpath /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/deploy.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/jconsole.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/plugin.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/sa-jdi.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/../Classes/charsets.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/../Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/../Classes/jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/../Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/../Classes/ui.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/apple_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/dnsns.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/localedata.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunjce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunpkcs11.jar:/Users/User/Documents/Scala3/out/production/Scala3:/Users/User/scala/lib/scala-library.jar:/Users/User/scala/lib/scala-swing.jar:/Users/User/scala/lib/scala-dbc.jar:/Applications/IntelliJ IDEA 10.app/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain DoIT
Exception in thread "main" java.lang.ClassNotFoundException: DoIT
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
So again it is a configuration problem. My first question, is this exception a step forwards or backwards? I would say "forwards" because I can at least try to run the Scala application ?! But what configuration is still wrong?
I got:
Project settings:
- Project SDK: 1.5
- Project Language Level: 1.5
Platform settings:
- SDKs: 1.5 and 1.6
- Global libraries: scala-compiler-2.9.0 and scala-library-2.9.0
Run Configuration:
- "Application"
- Main class: Hello (this is my class which extends from "App")
- use classpath and JDK of module (here I selected this module, at project creation I chose "project level" for libraries)
- use alternative JRE (again a link to Java 1.5) <= to be sure to start it with Java 1.5 not 6!
- no compilation errors
What the hell is still wrong with my Scala project?
Thanks for help...
I don't see anything that looks like your project's build output dir in that command-line.In fact, it's trying to run a class called "DoIT" and not "Hello" as you describe.
Just in case, could you make sure that you're running IDEA 10.5 (final release) and the latest Scala plugin nightly build[1]. When creating the run configuration, make sure that it has the module containing your class selected as the classpath to use.
1. http://confluence.jetbrains.net/display/SCA/Scala+Plugin+Nightly+Builds+for+IDEA+X
Sorry, my fault. New project => new class name :-)
Is it right that you have to use Java 5 instead of Java 6?
The about window tells me:
IntelliJ IDEA 10.5
Build: 107.105
16 May 2011
Java JDK: 1.6.0_24
I did not download the Scala plugin nightly build. Will do this now...
The JRE with which you run IDEA should have no effect on the JDK you use for your project. Scala is compatible with Java 5 and above.
Well, then I do not have anymore ideas what to do to get a Scala application running :-(
- Java 5 => Classpath problems (see above)
- Java 6 => Not able to even run the main method
- Eclipse Plugin => Works after 5 minutes... (because it is not really stable yet, I still would like to use IntelliJ IDEA)
I'm not sure what to suggest. I just created a working Scala application with the following steps in IDEA 10.5 using the latest Scala nightly plugin on Windows 7:
Test object source:
object Test {
def main(args: Array[String]) {
println("Hello World!")
}
}
Also tried it with:
println("Hello World!")
}
Which also worked.
The only thing I can think of is that perhaps this is a problem specific to IDEA on Mac?
Hey Gordon,
thanks.
Yes, it probably is a Mac problem. Maybe I will install IntelliJ in my VM on Windows and test it => Probably it will work, too. Unfortunately, the VM is slow and no long time solution, but it is worth a try.
Simply install Java (6) is not as easy as it is on Windows. I think the problem is here then...
Theoretically, the Java 6 that comes with Mac OS X should work for running IDEA and your application. There are no known limitations in this regard.
You could try disabling all your other third-party plugins and leave only Scala enabled.
Well, I did not use IntelliJ until now. I thought Scala would be a good opportunity to get started with it, because many people admire it :-)
There are no other plugins enabled, just Scala...
I just tried out Ubuntu in my VM. IntelliJ 10.0.2 is installed there. It uses Scala 2.8.1 and WORKS...
Well, this is much better than Windows in a VM, but I still hope to be able to use the Mac version.
My Mac had Java 5 installed. But I needed Java 6 for some applications (while some still need version 5). Thus, Java 5 and 6 are installed.
Thus, there probably is a problem with my Java installations which does not work correctly with IntelliJ...
IntelliJ 10.5 + Scala 2.9.0 also works on Ubuntu...
I just followed your steps exactly on Windows 7. Works like a charm.
On OSX, there is no "Run Test.main()" option on the conext-menu.
Seems like a OSX related plugin bug.
Running JAVA main()s from OSX works fine.
Are there any errors/exceptions recorded in the IDEA log file when you try this?
(On Windows, that file is located in ~/.IntelliJIdea10/system/log, not sure about Mac)
-tt
You won't believe it: After playing around with IntelliJ on Ubunta, I tried to integrate some Maven archetypes (which failed).
Now, I have the same problem on Ubunuta as on Mac OS X => "Run Scala Application" is no more available!!!
By the way: In the meanwhile, I got it working on Mac OS X. Problem was a bad Java 6 JDK installation. I used Soylatte because Mac JDK could not be downloaded on my Mac.
After making an Mac OS X update, Java 6 JDK was installed automatically. I now use this JDK, and everything works fine.
Unfortunately there was no speaking error message forwarding to this problem (though it may be logical, afterwards) :-)
But I am happy that I can use Scala with IntelliJ without starting a Virtual Machine, now...
Best regards,
Kai