如何只使用JRE就可以编译和运行没有JDK的java程序?

我在我的机器上安装了JRE并下载了Eclipse IDE并开始在该IDE上运行。 我从一些博客中读到,如没有JDK,我们无法编译java程序,但我可以在eclipse IDE中运行程序/应用程序。 然后在其他一些博客中给我提供的信息,比如eclipse将拥有自己的JDK,因此尝试在命令提示符下运行以获取已知信息。 当我尝试通过命令提示符编译bin文件夹(C:\ Program Files \ Java \ jre7 \ bin)中的程序时,它说javac无法识别。 我认为这是因为编译的类文件丢失,因为没有安装JDK,所以我从Eclipse IDE中复制了带有类文件的项目,并尝试运行它说无法找到的程序或加载主类filename.java。 即使我已将环境变量设置为JRE bin路径的Java_home。 请向我简要介绍JDK和JRE的区别。

如何在匿名内部类中使用外部方法的输入?

对于Instance,如何在我的Anonymou内部类中使用输入’hasTypedSomeToken’ – public class Login { void display(boolean hasTypedSomeToken) { //some code here Button btnLogIn = new Button(“Login”, new ClickHandler() { @Override public void onClick(ClickEvent event) { if(Login.this.hasTypedSomeToken) //HOW TO USE hasTypedSomeToken HERE { //do something } } } }

使用MongoDB的MapReduce Java驱动程序错误的BSONElement断言类型错误

我是MongoDB和MapReduce的新手。 我需要在我的数据库中的集合上做一些MapReduce。 MAP和REDUCE_MAX函数可以工作,因为我能够在Mongo交互式shell(v.1.8.2)中完成我的需求。 但是,使用Mongo Java驱动程序(v.2.6.3)尝试执行相同的操作时出错 我的MAP和REDUCE_MAX函数如下所示: String MAP = “function(){” + “if(this.type != \”checkin\”){return;}” + “if(!this.venue && !this.venue.id){return;}” + “emit({userId:this.userId, venueId:this.venue.id}, {count:1});” + “};”; String REDUCE_MAX = “function(key, values){” + “var res = {count:0};” + “values.forEach(function(value){result.count += value.count;});” + “return res;” + “};”; 这是我正在执行的命令: MapReduceOutput sum = collection .mapReduce(MAP, REDUCE_MAX, null, null); 这是我得到的错误: com.mongodb.CommandResult$CommandFailure: command […]

Spring Security OAuth 2,带有表单登录

我正在尝试配置我的Spring启动应用程序以使用表单登录,并使用OAuth 2授权服务器validation凭据(将表单登录中的凭据发送到用户授权URL。 但是,当我使用以下SecurityConfig并且我转到资源时,而不是使用表单登录,它会重定向到授权服务器,询问我的凭据(使用基本身份validation),然后重定向回应用程序本身。 我正在使用以下SecurityConfig : @Configuration @EnableOAuth2Sso public class SecurityConfig extends OAuth2SsoConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http .logout() .and() .antMatcher(“/**”) .authorizeRequests() .anyRequest().authenticated() .and() .csrf() .csrfTokenRepository(csrfTokenRepository()).and() .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class) .formLogin(); } // CSRF repository + filter } 我将formLogin()提供给configure()方法,但这似乎不起作用。 以下配置位于我的application.yml文件中: spring: oauth2: client: clientId: test clientSecret: secret accessTokenUri: http://localhost:8081/uaa/oauth/token userAuthorizationUri: http://localhost:8081/uaa/oauth/authorize clientAuthenticationScheme: header […]

如何将属性类型更改为String(WEKA – CSV到ARFF)

我正在尝试使用WEKA库制作SMS SPAM分类器。 我有一个带有“标签”和“文本”标题的CSV文件。 当我使用下面的代码时,它会创建一个包含两个属性的ARFF文件: @attribute label {ham,spam} @attribute text {‘Go until jurong point’,’Ok lar…’, etc.} 目前,似乎text属性被格式化为名义属性,每个消息的文本都是一个值。 但是我需要text属性是一个String属性,而不是所有实例中所有文本的列表。 将text属性作为String将允许我使用StringToWordVectorfilter来训练分类器。 // load CSV CSVLoader loader = new CSVLoader(); loader.setSource(new File(args[0])); Instances data = loader.getDataSet(); // save ARFF ArffSaver saver = new ArffSaver(); saver.setInstances(data); saver.setFile(new File(args[1])); saver.setDestination(new File(args[1])); saver.writeBatch(); 我知道我可以像这样创建一个String属性: Attribute tmp = new Attribute(“tmp”, (FastVector) null); 但我不知道如何替换当前属性,或者在读取CSV之前设置属性类型。 […]

Google的oauth端点正在返回“错误请求”……但为什么呢?

在https://accounts.google.com/o/oauth2/token请求代币时,在搜索“错误请求”的可能原因后浪费了大量时间,我决定问为什么此代码无法获取只是来自服务器的“错误请求”响应…… String url = “https://accounts.google.com/o/oauth2/token”; HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setChunkedStreamingMode(0); con.setRequestMethod(“POST”); con.setRequestProperty(“Host”, “accounts.google.com”); con.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”); con.setRequestProperty(“code”, authCode); con.setRequestProperty(“client_id”, “[CLIENT_ID]”); con.setRequestProperty(“client_secret”, “[CLIENT_SECRET”); con.setRequestProperty(“redirect_uri”, “http://localhost:8080/login”); con.setRequestProperty(“grant_type”, “authorization_code”); // Send post request con.setDoOutput(true); 我必须设置con.setChunkedStreamingMode(0)因为服务器返回了与内容长度相关的错误。 有任何想法吗? 是否有必要将有效载荷放在一条线上? 怎么样?

Java比较字符串

/** * A method to compare Strings * @param arg1 * @param arg2 * @return */ public boolean myQuickCompare(String arg1, String arg2) { boolean a = arg1.length() == arg2.length(); if (a) { for (int b = 0; b > arg1.length(); b++) { if (arg1.charAt(b) != arg2.charAt(b)) { a = false; } } } return a; […]

使用HttpClient上传video文件

我正在构建Java客户端,它将自动将文件从Java服务器上传到我使用他们的AMI安装在我的EC2云上的Panda Instance。 我正在尝试使用Apache HTTP Components上传到Panda Server( Panda Stream )。 它适用于我的浏览器客户端但由于某种原因我无法从该库上传。 这是我的代码: String videoUploadUrl = “http://[panda server ip]/videos/” + getVideoID() + “/upload.xml”; File file = new File(“/temp/videofile.mp4”); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpPost httppost = new HttpPost(videoUploadUrl); MultipartEntity mpEntity = new MultipartEntity(); ContentBody fBody = new FileBody(file); mpEntity.addPart(“userfile”, fBody); httppost.setEntity(mpEntity); System.out.println(“executing request ” + […]

如何链接TextView中的文本以打开Web URL

我花了一个多小时查看大量示例,但实际上没有一个能够在TextView中设置文本以链接到Web URL。 示例代码! text8 = (TextView) findViewById(R.id.textView4); text8.setMovementMethod(LinkMovementMethod.getInstance()); strings.xml中 Google main.xml中 目前此代码将文本显示为“Google”,但它没有超链接,点击时没有任何反应。

不支持的密码套件TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

我最近收到了Commodo的证书,我正在尝试将它与我的Scala Spray Server集成。 我有一个特性来配置我的Spray服务器: import java.io.{BufferedInputStream, FileInputStream} import java.security.{SecureRandom, KeyStore} import java.security.cert.{X509Certificate, CertificateFactory} import javax.net.ssl.{TrustManagerFactory, KeyManagerFactory, SSLContext} import spray.io._ import org.apache.camel.util.jsse._ // for SSL support (if enabled in application.conf) trait MySSLConfig { // if there is no SSLContext in scope implicitly the HttpServer uses the default SSLContext, // since we want non-default settings in this […]