 
   controller = null
   java_handler = null
-  showPrompt = null
   user_input = (n_bytes, resume) ->
     oldPrompt = controller.promptLabel
     controller.promptLabel = '> '

      [cmd,args...] = line.split ' '
      switch cmd
        when 'javac'
          compile_source editor.getSession().getValue(), report
        when 'java'
          return false unless class_data?
          stdout = (str) -> report str, true # no reprompting
          rs ?= new runtime.RuntimeState(stdout, user_input, read_classfile)
          jvm.run_class(rs, class_data, args, ->
            $('#heap_size').text rs.heap.length-1
            controller.reprompt()
          )
        when 'clear_heap'
          rs = null
          $('#heap_size').text 0
          "Heap cleared."
        when 'help'
          """
javac -- Compile and display disassembly.
java [args...] -- Run with command-line arguments.
clear_heap -- Clear the heap.
          """
        else
          "Unknown command #{cmd}. Enter 'help' for a list of commands."


process_bytecode = (bytecode_string) ->
  bytes_array = util.bytestr_to_array bytecode_string
  new ClassFile(bytes_array)

compile_source = (fname, cb) ->
  source = localStorage["file::#{fname}"]
  return cb "Could not find file '#{fname}'" unless source?
  $.ajax 'http://people.cs.umass.edu/~ccarey/javac/', {
    type: 'POST'
    data: { pw: 'coffee', source: source }
    dataType: 'text'
    beforeSend: (jqXHR) -> jqXHR.overrideMimeType('text/plain; charset=x-user-defined')
    success:  (data) ->
      class_name = fname.split('.')[0]
      localStorage["file::#{class_name}.class"] = data
      class_data = process_bytecode(data)
      cb?(true)
    error: (jqXHR, textStatus, errorThrown) -> 
      cb?("AJAX error: #{errorThrown}")
  }
