i'm looking at some example code that is erroring out in scala 2.9.1:
import javax.swing.JFrame
import javax.swing.JMenuBar
import javax.swing.JButton
import javax.swing._
import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
import javax.swing.{UIManager}
object UI extends SimpleSwingApplication {
UIManager.setLookAndFeel(new NimbusLookAndFeel)
}
error: /some/path/Cls.scala:25: error: not found: type SimpleSwingApplication
turns out i had to run my code like so:
scala -classpath /usr/share/java/scala-swing.jar Cls.scala
the code base that was successful is:
import javax.swing.JFrame
import javax.swing.JMenuBar
import javax.swing.JButton
import javax.swing._
import scala.swing.SimpleSwingApplication
import scala.swing._
object UI extends SimpleSwingApplication {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
def top = new MainFrame {
title = "First Swing App"
contents = new Button {
text = "Click me"
}
}
def main() {
println("hi")
}
}
Related
the spring boot REST app with MySQL
I am trying to add record to DB and expect the record added and postman got it as output instead of the output "status":404,"error":"Not Found","path":"/api/employees" following is the classes
package com.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.service.EmployeeService;
import com.model.Employee;
#RestController
#RequestMapping("/api")
public class EmployeeController {
private EmployeeService employeeservice;
public EmployeeController(EmployeeService employeeservice) {
super();
this.employeeservice = employeeservice;
}
//build create Employee REST API
#PostMapping("/employees")
public ResponseEntity<Employee> saveEmployee(#RequestBody Employee employee)
{
return new ResponseEntity<Employee>(employeeservice.saveEmployee(employee), HttpStatus.CREATED);
}
}
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
#EnableJpaRepositories(
basePackages = {"com.model"})
#SpringBootApplication(scanBasePackages = {"service.impl"})
public class RestapimysqlApplication {
public static void main(String[] args) {
SpringApplication.run(RestapimysqlApplication.class, args);
}
}
It doesn't look like you're scanning the package that contains your REST controller (i.e. com.controller), seems like you're only scanning the service.impl package on your RestapimysqlApplication class.
You should probably add the com.controller to the list of packages being scanned by Spring here:
#EnableJpaRepositories(basePackages = {"com.repository"})
#SpringBootApplication(scanBasePackages = {"service.impl", "com"})
#EntityScan({"com.model"})
public class RestapimysqlApplication {
...
}
I'm developing a custom skill to Alexa (Amazon), and I coded the skill in lambda AWS service in JAVA 8. I'm trying to get a simple response from my ask2decide API and it's not working.
Basically I'm executing the following code:
String questiont = "casco"
String queryString =
String.format("https://www.ask2decide.com/api/prod/search.php?s=%s", questiont);
InputStreamReader inputStream = null;
BufferedReader bufferedReader = null;
StringBuilder builder = new StringBuilder();
try {
String line;
URL url = new URL(queryString);
inputStream = new InputStreamReader(url.openStream(), Charset.forName("US-ASCII"));
bufferedReader = new BufferedReader(inputStream);
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
System.out.println(line);
}
} catch (IOException e) {
// reset builder to a blank string
System.out.print("ERROR:");
System.out.println(e);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(bufferedReader);
}
The result of executing it is the following
error:"javax.net.ssl.SSLHandshakeException: Remote host closed
connection during handshake"
Note: I get a JSON standard array if I execute the URL in Chrome without any error.
Note2: The imports:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.security.*;
import javax.net.ssl.*;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazon.speech.slu.Intent;
import com.amazon.speech.slu.Slot;
import com.amazon.speech.speechlet.IntentRequest;
import com.amazon.speech.speechlet.LaunchRequest;
import com.amazon.speech.speechlet.Session;
import com.amazon.speech.speechlet.SessionEndedRequest;
import com.amazon.speech.speechlet.SessionStartedRequest;
import com.amazon.speech.speechlet.SpeechletV2;
import com.amazon.speech.speechlet.SpeechletResponse;
import com.amazon.speech.json.SpeechletRequestEnvelope;
import com.amazon.speech.ui.OutputSpeech;
import com.amazon.speech.ui.PlainTextOutputSpeech;
import com.amazon.speech.ui.SsmlOutputSpeech;
import com.amazon.speech.ui.Reprompt;
import com.amazon.speech.ui.SimpleCard;
import com.amazonaws.util.json.JSONArray;
import com.amazonaws.util.json.JSONException;
import com.amazonaws.util.json.JSONObject;
import com.amazonaws.util.json.JSONTokener;
I am trying to import my original package.
But it is said that there is no class files form Akirasda1972_001.as.
My package file is uploaded on sexydesign.club/particle/.
package{
import flash.display.Sprite;
import club.sexydesign.particle.Akirasada1972_001;
public class akirasada1972_002 extends Sprite{
private var akirasada1972_001:Akirasada1972_001;
public function akirasada1972_002():void{
akirasada1972_001=new Akirasada1972_001();
akirasada1972_001.Akirasada1972_001();
addChild(akirasada1972_001);
}
}
}
I am using Flash Builder 4.7 and have created a Worker Class. Below is the code:
package co.fuix.mobile.system.model
{
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.Event;
import flash.system.MessageChannel;
import flash.system.Worker;
import flash.utils.getDefinitionByName;
import mx.managers.SystemManager;
public class InstantMessengerWorker extends Sprite
{
private var bm:MessageChannel;
private var mb:MessageChannel;
public function InstantMessengerWorker()
{
super();
bm = Worker.current.getSharedProperty("BACK_TO_MAIN_CHANNEL");
mb = Worker.current.getSharedProperty("MAIN_TO_BACK_CHANNEL");
mb.addEventListener(Event.CHANNEL_MESSAGE, onMainToBack);
}
protected function onMainToBack(event:Event):void
{
if(mb.messageAvailable){
var s:SystemManager;
trace('*'+mb.receive());
trace('**'+mb.receive());
trace('***'+mb.receive());
trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
}
}
}
}
How do I reference a variable in the main mxml file. I know how to use message channels but I want to get that variable straight.
When I run the above code, this part
trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
is giving me an error.
Any help will be regreatly appreciated
You can't access a variable from the main app like that. They are running separately. What you need to do is:
Link to Adobe docs
package
{
import flash.display.MovieClip;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class PencereyiGizle extends MovieClip
{
public var natWindow:NativeWindow=new NativeWindow(
new NativeWindowInitOptions());
public var pencereyiAc_Btn:Button;
public function PencereyiGizle(fro:Button)
{
pencereAc_Btn = fro;
//Pencere ekleniyor
natWindow.width = 500;
natWindow.height = 400;
natWindow.activate();
natWindow.addEventListener(Event.CLOSING,pencereyiSakla);
pencereyiAc_Btn.label = "Pencereyi Ac";
pencereyiAc_Btn.addEventListener(MouseEvent.MOUSE_DOWN,pencereyiAktifEt);
}
//pencerenin kapanmasını engelleyip pencereyi gizliyoruz.;
private function pencereyiSakla(e:Event):void
{
e.preventDefault();
natWindow.visible = false;
}
//gizlenen pencereyi tekrar aktif hale getiriyoruz
private function pencereyiAktifEt(e:MouseEvent):void
{
natWindow.activate();
}
}
}
IN AIR;
import PencereyiGizle;
var firat:PencereyiGizle= new PencereyiGizle();
addChild(firat);
and then, i get that problem "1046: Type was not found or was not a compile-time constant:Button. "
Based on what is in your imports, I think you want to use the SimpleButton class and not the Button class. (Which is a flash component)
Either that or you are missing this import
import fl.controls.Button;
Here is an artilce from adobe on the button component.
http://www.adobe.com/devnet/flash/quickstart/button_component_as3.html