Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

How to debug Play applications setup with the Typesafe stack from IntelliJ May 23, 2012

Filed under: IntelliJ,playframework,Web — Rupert Bates @ 8:18 pm
Tags: , ,

Windows:
Set your sbt.bat to the following:

set SCRIPT_DIR=%~dp0
set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999
java %SBT_OPTS% -Xmx512M -XX:MaxPermSize=256m -jar “%SCRIPT_DIR%sbt-launch.jar” %*

Run SBT in your project folder and then the ‘run’ command

In IntelliJ set up a run configuration (Run/Edit Configurations) as follows:

Add a new ‘Remote’ configuration
Give it a name
Set transport to ‘Socket’
Set debugger to ‘Attach’
Set host to localhost set port to 9999 (so it matches the port you set in SBT_OPTS in the sbt.bat file)

Put in some breakpoints and hit debug.

 

I’ll add in Linux/MacOs instructions next time I’m at a Linux box…

 

Error .apk.res not found In IntelliJ Idea Android project January 27, 2011

Filed under: Android,Error,Git,IntelliJ,Java — Rupert Bates @ 10:32 am

After pulling the latest source of an android project I am working on from GitHub I got the following error:


MyProject.apk.res not found. Try to rebuild project

But no amount of rebuilding would fix it.
It turned out that the problem was that somehow the Module had lost track of which Android platform it is targeted to. To fix it I did the following:

  1. Bring up the Project Structure dialog (File/Project Structure or ctrl+alt+shift+s)
  2. Make sure that Modules is selected in the Project settings pane (far left)
  3. Expand the node with the name of your project in the middle pane and click on the Android node underneath it. This selects the Android facet.
  4. At the top of the Facet pane there is a drop-down list which you can use to select your Android platform. If there are no entries in this you can create a new one by clicking ‘New’ and locating the directory your Android SDK is installed in.
  5. Click Ok and rebuild, the problem should now be fixed

It seems that the problem is caused by Git in some way, but I’m not exactly sure how yet. I’ll update here if I find out why.

 

error: value tools is not a member of package scala when using the scala console in IntelliJ IDEA October 20, 2010

Filed under: Error,IntelliJ,Scala — Rupert Bates @ 3:28 pm

If you get the following error whilst trying to use the scala console in Intellij IDEA:


<script>:3: error: value tools is not a member of package scala
var value: scala.tools.nsc.InterpreterSettings = _
^
<script>:4: error: value tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^
Exception in thread "main" java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:185)
at scala.None$.get(Option.scala:183)
at scala.tools.nsc.Interpreter.bind(Interpreter.scala:622)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at scala.util.control.Exception$Catch.apply(Exception.scala:79)
at scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:630)
at scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:276)
at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:584)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:597)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:575)
at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:471)
at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:514)
at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:361)
at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:242)
at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:248)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:558)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:609)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

You can fix it as follows:

  1. From the ‘Run’ menu click ‘Edit Configurations’
  2. Select the Scala Console run configuration and type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Apply

To make this the default for all Scala ConsoleĀ  run configurations

  1. right click on the top leve Scala Console icon and select ‘Edit Defaults’
  2. Type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Ok

It should now work correctly

 

How to add a project reference – an introduction to IntelliJ IDEA 9 for Visual Studio users October 9, 2010

Filed under: IntelliJ,Java,Visual Studio — Rupert Bates @ 1:19 pm

To add a reference to an external library (the equivalent of right clicking on project references and selecting ‘Add’ in VS):

  1. Goto Project structure dialog (File\Project structure or Ctrl+Alt+Shift+S)
  2. In the ‘Project settings’ pane select Modules
  3. Make sure your project is selected in the middle pane
  4. Click the dependencies tab in the right hand pane

You can now add and delete dependencies on libraries (equivalent to adding a project reference).

There are a number of different types of depency you can add, here they are with my best guesses at how they translate into Visual Studio terminology:

  1. Single entry module – a reference to a single jar file – same as adding a reference to a dll in VS
  2. Module library – a reference to a group of jar files (accessible only to this module?) – no real equivalent in VS
  3. Project library – a reference to a group of jar files (accessible to whole project?) – no real equivalent in VS
  4. Global library – a reference to a group of jar files (accessible to all projects?) – similar to adding a reference to a dll in the GAC
  5. Module dependency – a reference to another project – same as a project reference in VS