Configuring Scala compiler in IntelliJ 10.5? - scala

I'm trying to get Scala working correctly in IntelliJ 10.5.1. I installed the plugin from the "available plugins" settings and then tried starting a new Java project, selecting "scala" under available technologies. But when I try running it, Scala says I haven't defined a scala compiler in the scala facet. So I went there, but I don't see any way of setting up the compiler. Also, my .iml file in my project looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="scala" name="Scala">
<configuration>
<option name="compilerLibraryLevel" value="Global" />
<option name="pluginPaths">
<array>
<option value="$USER_HOME$/SDKs/scala/src/scala-compiler-src.jar" />
</array>
</option>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="scala " level="application" />
</component>
</module>
Notice that it does seem to be pointing to the correct jar compiler destination.
What do I need to do?
EDIT -
Compiler working now, but when I run, i get this error:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Didea.launcher.port=7540 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10 CE.app/bin -Dfile.encoding=UTF-8 -classpath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-string.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/charsets.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home:/Users/me/Projects/Scala/testing/out/test/testing:/Users/me/Projects/Scala/testing/out/production/testing:/Users/me/SDKs/scala/lib/scala-library.jar:/Users/me/SDKs/scala/lib/scala-swing.jar:/Users/me/SDKs/scala/lib/scala-dbc.jar:/Applications/IntelliJ IDEA 10 CE.app/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain hello_world
Exception in thread "main" java.lang.ClassNotFoundException: hello_world
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Process finished with exit code 1

Go to project settings (that could be invoked by Ctrl+Alt+Shift+S) and choose scala-compiler in libraries list just like that:
Now FacetManager component looks like this:
<component name="FacetManager">
<facet type="scala" name="Scala">
<configuration>
<option name="compilerLibraryLevel" value="Global" />
<option name="compilerLibraryName" value="scala-compiler-2.9.0.1" />
</configuration>
</facet>
</component>

See the Project Configuration Guide.
If you use SBT to build, I recommend using sbt-idea to generate your IDEA project, and idea-sbt-plugin to delegate project compilation within IDEA to SBT.

I guess you need to add the scala compiler library to the global libraries. In the module settings-> Global Libraries -> attach jar directories and select the lib folder under scala installation directory and then do as om-nom-nom suggested to make sure the compiler is selected.

Related

Build Path in eclipse

After importing my existing GWT project to Eclipse getting the following error.
Project 'TestUI' is missing required source folder: 'TestMgr/nocache/js.gwt.xml'.
Please help.
Please post your module gwt.xml. You should ensure the entry point classpath is correct
<!-- Specify the app entry point class. -->
<entry-point class="com.me.myproject.client.TestUI" />
And check that you added the appropriate packages to your module
<!-- Adding package to this gwt module -->
<source path="client" />
<source path="shared" />
If everything is fine with the module, could you be more specific about where that error happens ? When launching your project ? In Eclipse warnings ?

How to correctly specify eclipse-plugins in category.xml of tycho eclipse-repository?

I want to create a p2 repository of some eclipse-plugins during a tycho build.
My category.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="plugins/<artifact-id>-1.0.0.jar"
id="<artifact-id>" version="1.0.0.qualifier">
<category name="cat" />
</feature>
<category-def name="cat" label="example category" />
</site>
where <artifact-id> is the maven artifact id of the eclipse-plugin that shall be included in the p2 repo.
When executing the maven build I get the following error message:
[ERROR] Internal error: java.lang.RuntimeException: "No solution found
because the problem is unsatisfiable.": ["Unable to satisfy dependency
from <repository-module-artifact-id> 1.0.0.qualifier to
<artifact-id>.feature.group[1.0.0,1.0.1).", "No
solution found because the problem is unsatisfiable."]
I have included the eclipse-plugin in the dependencies of the repository-module.
What am I missing here?
as of now you can only reference features in category.xml.
recently there was a patch that will allow referencing individual bundles in a future version of tycho, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=381377

Deploying a JavaFX 2 application with referenced jars, using Ant

I have written a JavaFx 2 application (using Eclipse on a Windows platform) and now I want to deploy it to a "clickable" jar-file. My application uses resource-code from a separate jar-file (in Eclipse, this resource code is a separate Project from the JavaFx application project).
With my Ant build.xml, I have compiled the code for both the application and the resource code and created two jar-files:
fxdemo.jar - A jar for my JavaFx application code
guifw.jar - A jar for the resource code referenced by the JavaFx application.
As a last step (I thought), using the JavaFX Ant tasks, I wanted to bundle these two jar-files to a "clickable" jar that starts my JavaFX application. I tried doing just that with the below extract from my build.xml.
<target name="deployFx" depends="fxdemo.jar" description="Releases FxDemo">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath=".:${fxgui.javaHome}\lib\ant-javafx.jar"/>
<copy file="${fxgui.lib_guifw_path}" tofile="delivery/lib/guifw.jar"/>
<fx:application id="FxDemoGUI" name="Fx Demo GUI" MainClass="com.demo.main.MainGUI"/>
<fx:resources id="jars">
<fx:fileset dir="delivery/lib" includes="fxdemo.jar"/>
<fx:fileset dir="delivery/lib" includes="guifw.jar"/>
</fx:resources>
<fx:jar destfile="deploy/fxDemoGui.jar">
<!-- Define what to launch -->
<fx:application refid="FxDemoGUI"/>
<fx:platform javafx="2.1+">
<fx:jvmarg value="-Xms32m"/>
<fx:jvmarg value="-Xmx32m"/>
<property name="com.util.fxguifw.setup" value="com/util/fxguifw/demo/demo.properties"/>
<property name="user.language" value="en"/>
<property name="user.country" value="GB"/>
<property name="CSS_ID" value="NIGHT"/>
</fx:platform>
<fx:resources>
<fx:fileset dir="delivery/lib" includes="fxdemo.jar"/>
<fx:fileset dir="delivery/lib" includes="guifw.jar"/>
</fx:resources>
<manifest>
<attribute name="Implementation-Vendor" value="${fxgui.vendor}"/>
<attribute name="Implementation-Title" value="${fxgui.title}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
<fileset dir="delivery"/>
</fx:jar>
However, afterwards when I try to start the application (by either clicking the jar or starting from command line with java -jar appname.jar) it seems as the application can not find the Main class:
JavaFX Launcher Error
Unable to find class: com.demo.main.MainGUI
C:\Program Files\Java\jdk1.7.0_09\bin>java -jar C:\MEKMAN\Clearcase_Views\wmarekm_ss_gambau\amb_c2_prototype\javafx\prototypeGUI\deploy\fxDemoGui.jar
java.lang.ClassNotFoundException: com.demo.main.MainGUI
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.javafx.main.Main.getAppClass(Main.java:506)
at com.javafx.main.Main.launchApp(Main.java:622)
at com.javafx.main.Main.main(Main.java:805)
When I studie the created MANIFEST.MF (in the created jar-file) it looks pretty much as what I expected.
Manifest-Version: 1.0
JavaFX-Version: 2.1+
implementation-vendor: MyVendor
implementation-title: MyfirstJavaFxDeploy
implementation-version: 1.0
JavaFX-Application-Class:com.demo.main.MainGUI
JavaFX-Class-Path: fxdemo.jar guifw.jar
Created-By: JavaFXPackager
Main-Class: com/javafx/main/Main
... but then again, it doesn't work so obviously I have done something wrong.
I also tried including the classes-directory (the output folders from each of the two Eclipse/projects) by adding:
<fileset dir="../guifw/classes"/>
<fileset dir="classes"/>
Then, the launcher does find my main class (com.demo.main.MainGUI) but failes to run correctly because it lacks the -D argument that I tried to specify with:
<property name="com.util.fxguifw.setup" value="com/util/fxguifw/demo/demo.properties"/>
So, if you have read this far, my questions are:
Why can't the launcher find my main class in the referenced jar (fxdemo.jar)?
What have I done wrong when it comes to specify my -D arguments to the application?
Best regards
I studied/tested the fix presented in post (2012-apr-12 03:32) in the link from #Anders Petersson:
Link from #Anders Petersson
From what I can see, this is a workaround that unbudles any used jar-file (in my case; guifw.jar & demofx.jar) within the resulting jar file (fxDemoGui.jar), much like adding the classes-folders from my two Eclipse-projects (as described in the question).
I adjusted the example to my build.xml and got it to work after one slight addition:
<target name="dist" depends="fxdemo.jar">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath=".:${fxgui.javaHome}\lib\ant-javafx.jar"/>
<copy file="${fxgui.lib_guifw_path}" tofile="delivery/lib/guifw.jar"/>
<fx:jar destfile="predeploy/fxDemoGui.jar">
<!-- ADDITION -> Adds the Launcher's Main class to the resulting jar (com.javafx.main.Main)! -->
<fx:application id="FxDemoGUI"
name="Fx Demo GUI"
mainClass="com.demo.main.MainGUI"/>
<fileset dir="delivery"/>
</fx:jar>
</target>
In the dist-target from the example, I had to add:
<fx:application id="FxDemoGUI"
name="Fx Demo GUI"
mainClass="com.demo.main.MainGUI"/>
Without it, the resulting jar-file did not have the necessary com.javafx.main.Main-class and hence, failed to start.
So, this solution presents a useful workaround for my question 1)
Still, I'd be grateful if anyone comes up with a solution on how to keep the jar-files intact within the resulting jar/file.

Have added Ivy management to Eclipse project, then what?

Have added Ivy management to one of my eclipse projects. Nothing happened after that.
I have a guide to add something to ivy.xml and ivysettings.xml, so what? How to create empty versions of these files? Where to put them?
I have created some by intuition, in the project root, then added to files what was told.
Nothing happened. Where are new libraries? How to force Ivy to do something?
Versions:
Apache IvyDE 2.2.0.beta1-201203282058-RELEASE
Eclipse Helios Service Release 2
Guides for ivy are for xuggler: http://www.xuggle.com/downloads
I have created ivy.xml by File New and added what was said without ellipsis. icysettings.xml are just the sample w/o ellipsis.
Yes ivy.xml should be in the root (for default configuration).
try this:
<ivy-module
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.organisation" module="stackoverflow" revision="1.0.0" status="integration" >
</info>
<configurations>
<conf name="default" />
</configurations>
<dependencies>
<dependency org="xuggle" name="xuggle-xuggler" rev="5.2" />
</dependencies>
</ivy-module>
Create ivysettings.xml file in the root as well. This one is adapted to your need
<ivysettings> <
settings defaultResolver="default" />
<include url="${ivy.default.settings.dir}/ivysettings.xml" />
<resolvers>
<url m2compatible="true" name="xugglecode">
<ivy
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[organization]/[artifact]/[revision]/ivy-[revision].xml" />
<ivy
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[organization]/[artifact]/ivy-[revision].xml" />
<artifact
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" />
<artifact
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[organisation]/[artifact]/[artifact](-[revision]).[ext]" />
<artifact
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[organisation]/[artifact](-[revision]).[ext]" />
<artifact
pattern="http://xuggle.googlecode.com/svn/trunk/repo/share/java/[artifact](-[revision]).[ext]" />
<artifact
pattern="http://build.xuggle.com/view/Stable/job/red5_jdk6_stable/lastSuccessfulBuild/artifact/workingcopy/dist/[artifact].[ext]" />
</url>
<chain name="default" changingPattern=".*SNAPSHOT">
<resolver ref="xugglecode" />
</chain>
</resolvers>
</ivysettings>
Now when you add ivy management, in Main tab you should see Ivy File: ivy.xml as default.
now go to settings tab. Check the box of 'Enable project specific settings'.
in Ivy settings path, easier to choose the one you just created in your root project using 'Workspace button'. Navigate and choose.
Press ok. It will start resolving immediately.
I should tell you, that even though the file exists, I couldn't retrieve it. The ivy- console seems stuck. I'm receiving Status Code 403. I'm doing from work.
Maybe you have better luck resolving it. If not, consider this as a mini example of how to set up IvyDE.

deploying OSGi project as Webstart using command line tools

How do I create a modular OSGi project that can be distributed with Java Webstart, using command line tools?
I've found instructions to export a set of OSGi plugins from eclipse. But instructions for doing so without the help of eclipse are hard to find. I would like to do this using ant build scripts and / or other command line tools.
Here is what I've got so far. Using ant, all the plug-in bundles are copied to a directory and signed. After that, I've created a jnlp file named wrapper.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="wrapper.jnlp">
<information>
<title>My app</title>
<vendor>Me</vendor>
<offline-allowed/>
</information>
<resources>
<j2se version="1.5+" java-vm-args="-Xmx512M"/>
<jar href="org.eclipse.equinox.launcher.jar"/>
<extension name="Wrapper feature" href="myprogram.jnlp"/>
</resources>
<application-desc main-class="org.eclipse.equinox.launcher.WebStartMain"/>
<security>
<all-permissions/>
</security>
</jnlp>
I've created a second jnlp file named myprogram.jnlp.
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="myprogram.jnlp">
<information>
<title>My app</title>
<offline-allowed/>
</information>
<resources>
<j2se version="1.5+" java-vm-args="-Xmx512M"/>
<jar href="myapp.jar"/>
<jar href="derby.jar"/>
<jar href="commons-math-2.0.jar"/>
...omitting a dozen more jar files...
</resources>
<application-desc main-class="myprogram.Main"/>
<security>
<all-permissions/>
</security>
</jnlp>
When I deploy and try to start it (from the command line: javaws http://localhost/webstart/wrapper.jnlp), the jar files of the application appear to be downloaded. Then I get the following error in a log file:
!SESSION Wed Jun 29 13:43:52 CEST 2011 -----------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2011-06-29 13:43:52.448
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:411)
at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartMain.java:78)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:590)
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)
Any idea what I'm doing wrong? Where should I look next?
I had the same issue. I solved it by specifying the following in my wrapper jnlp:
<resources>
<!-- Reference to the launcher jar. The version segment must be updated to the version being used-->
<jar href="plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" />
<!-- Reference to the osgi jar. The version segment must be updated to the version being used-->
<jar href="plugins/org.eclipse.osgi_3.7.0.v20110613.jar" />
...
</resources>
I believe you might want to switch gears and create a P2 repository with your code and all dependencies, then have a bare-bones p2-installer pull the dependencies from there (bypassing WebStart) and start your application.
Have a look at this http://www.jbundle.org/osgi-webstart/ "Use this servlet to deploy your OSGi apps to a web client."
Though it's a maven plugin from the documentation it looks like you can run it without a maven project.
According to the sources, your problem is caused by failing to find org.eclipse.osgi bundle on the classpath. Make sure that the bundle is referenced properly and that it has correct manifest.