Java 8不兼容的类型

这是简单的代码 import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class SimpleTest { public static void main(String[] args) { final ArrayList<Map> maps = newArrayList( createMap(“1”, “a”, Collections.EMPTY_MAP, Collections.EMPTY_MAP), createMap(“2”, “b”, Collections.EMPTY_MAP, Collections.EMPTY_MAP), createMap(“3”, “c”, Collections.EMPTY_MAP, Collections.EMPTY_MAP) ); System.out.println(” maps = ” + maps); } public static Map createMap(String value1, String value2, Map object1, Map object2) […]

调用C子例程时出现JNI错误

我想从Java调用一个C子例程。 我正在使用JNI。 我创建了.java,.c和.h文件,并编译了一个DLL。 所有文件都在同一个文件夹中。 但是当我运行程序时,它显示了一个unsatisfiedlinkError 。 我哪里错了……? 在我学习JNI时,我使用的源代码来自: http : //www.ibm.com/developerworks/java/tutorials/j-jni/section2.html以及我已经尝试过的内容: 使用Code :: Blocks(ide)和GCC作为编译器创建一个dll 从命令行使用GCC创建dll(参考http://sig9.com/node/35 ) 我使用Win7 32位,我猜上面的所有方法都生成32位DLL 我找到的用于创建DLL(共享库)的所有解决方案都是针对MS VC / VCPP的,我现在在我的机器上没有。 哪里有问题? 生成DLL文件没有任何exception,但是当我运行Java代码时,它会抛出exception。 PS:如果有任何理论上的例子可以解释JNI的工作原理以及它的实际作用,那么请分享链接…… 抛出的消息或exception: c:\myjava1>java Sample1 Exception in thread “main” java.lang.UnsatisfiedLinkError: Sample1.intMethod(I)I at Sample1.intMethod(Native Method) at Sample1.main(Sample1.java:11) 在创建dll文件很多次后的一天结束时,我很确定它可能没有问题,路径有问题…我已经用load方法更改了loadlibrary方法,但仍然没有运气,….. 正如MOD建议的那样:我一直在讨论这个问题:调用C子程序时JNI错误,我在这里发布所有代码,因为注释有限的字符… Sample1.c #include “jni.h” #include”Sample_Sample1.h” JNIEXPORT jint JNICALL Java_Sample_Sample1_test(JNIEnv *env, jobject obj){ return(1); } void […]

Netty WriteAndFlush方法不起作用

看哪以下代码: public final class SecureChatClient { static final String HOST = System.getProperty(“host”, “127.0.0.1”); static final int PORT = Integer.parseInt(System.getProperty(“port”, “8992”)); public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE); EventLoopGroup group = new NioEventLoopGroup(); try { Bootstrap b = new Bootstrap(); b.group(group) .channel(NioSocketChannel.class) .handler(new NetworkInitializer(sslCtx)); // Start the […]

Android – Http获取请求

我正在尝试使用下面的代码获取请求,但stringbuilder始终为null。 url是正确的…… http://pastebin.com/mASvGmkq 编辑 public static StringBuilder sendHttpGet(String url) { HttpClient http = new DefaultHttpClient(); StringBuilder buffer = null; try { HttpGet get = new HttpGet(url); HttpResponse resp = http.execute(get); buffer = inputStreamToString(resp.getEntity().getContent()); } catch(Exception e) { debug(“ERRO EM GET HTTP URL:\n” + url + “\n” + e); return null; } debug(“GET HTTP URL OK:\n” […]

任何人都可以告诉我,类中静态块的用途是什么?

public class myclass{ static{ //some statements here } //some variables declared here //some functions defined here }

使用java execute shell命令

这个类是响应执行命令,打印结果 public class ExecutorTask implements Runnable{ @Override public void run() { Process process = null; try { process = Runtime.getRuntime().exec(“cmd /c dir”); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line=””; while ((line = reader.readLine()) != null) { System.out.println(line); } process.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { return; } } } […]

Java 8流filter – 基于排序的pdate

我试图在filter中对字段进行排序。 输入文件/样本记录: DocumentList: [ Document{ { _id=5975ff00a213745b5e1a8ed9, u_id=, mailboxcontent_id=5975ff00a213745b5e1a8ed8, idmapping=Document{ {ptype=PDF, cid=00988, normalizedcid=00988, systeminstanceid=, sourceschemaname=, pid=0244810006} }, batchid=null, pdate=Tue Jul 11 17:52:25 IST 2017, locale=en_US } }, Document{ { _id=597608aba213742554f537a6, u_id=, mailboxcontent_id=597608aba213742554f537a3, idmapping=Document{ {platformtype=PDF, cid=00999, normalizedcid=00999, systeminstanceid=, sourceschemaname=, pid=0244810006} }, batchid=null, pdate=Fri Jul 28 01:26:22 IST 2017, locale=en_US } } ] 在这里,我需要基于pdate进行排序。 List outList = […]

在gradle更新后无法找到方法(无法编译项目)

我尝试按照这些说明将项目中的gradle版本更新为4.1-milestone-1 我当前的gradle-wrapper.properties文件: #Sat Jun 17 21:17:43 IDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=\ https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip 我当前的项目build.gradle文件buildscript buildscript { ext.kotlin_version = ‘1.1.3’ apply from: ‘dependencies.gradle’ repositories { jcenter() mavenCentral() google() } dependencies { classpath ‘com.android.tools.build:gradle:3.0.0-alpha5′ …. } …. } 在尝试编译项目时,我收到此错误: 错误:(1,0)无法找到方法’com.google.common.base.Preconditions.checkArgument(ZLjava / lang / String; Ljava / lang / Object; Ljava / lang / Object; Ljava / […]

无法从包含DEX和Java字节码内容的archive \ app \ libs \ appodeal-2.1.11.jar’创建Android应用程序

我正在尝试将appodeal jar文件添加到我的项目中,但是会发生以下错误: Cannot create android app from an archive app\libs\appodeal-2.1.11.jar’ containing both DEX and Java-bytecode content android.enableD8 = false也不起作用。 我正在使用buildToolsVersion 3.1.3,gradle-4.8和multidex-1.0.2库。 我该如何解决这个问题? 谢谢

我如何将spring mvc应用程序打包到jar?

我有一个使用maven和spring mvc和tomcat7-maven-plugin构建的应用程序。 我可以将这些打包到jar文件中,以便我可以运行jar文件来启动tomcat服务器吗? 这意味着我不需要tomcat,只有jar文件可以提供web服务。