Java 7是否有办法将文件放入回收站而不是在WIndows上删除?我知道它在Java 6中不存在,但我真的认为这已经被添加到Java 7但是一直无法找到它,如果不是有第三方库可以做到这一点,我不想小提琴和JNI一起.
您是否可以使用Apple扩展在OSX上执行此操作
com.apple.eawt.FileManager.moveToTrash()
Run Code Online (Sandbox Code Playgroud)
编辑: 使用jna库作为答案.FWIW它可以在maven中央存储库上使用,但是您需要包含jna pom和平台pom,因为平台jar是包含回收站方法的平台jar.
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>platform</artifactId>
<version>3.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) 刚刚从Tomcat 6迁移到Tomcat 7并注意到当您部署名为widget的webapp时,META-INF/context.xml不再被复制到conf/Catalina/localhost/widget.xml.
我不清楚它是否需要,如果保留在META-INF中,是否会使用context.xml中的设置,或者如果移动到conf/Catalina/localhost/widget.xml它们是否只有效果
我使用香草tomcat 7安装
它适用于我,但在特定客户的OSX Mavericks上,InetAddress.getLocalHost()在Java 7中失败,尽管它在Java 6中运行正常,但有以下异常
java.net.UnknownHostException: rupert: rupert: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1466)
Caused by: java.net.UnknownHostException: rupert: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286)
at java.net.InetAddress.getLocalHost(InetAddress.java:1462)
Run Code Online (Sandbox Code Playgroud)
这是设计的吗?
更新
看起来是Java 8中修复的已知错误
我安装了Postgres扩展(unaccent)
sudo su posgres
psql create extension unaccent
Run Code Online (Sandbox Code Playgroud)
现在我可以在sql中使用unacccent,但前提是我是Postgres用户.
如何向所有/另一个用户提供Postgres扩展
(我在Ubuntu上使用apt-install安装Postgres 9.3.5)
jthinksearch=# \dx;
List of installed extensions
Name | Version | Schema | Description
----------+---------+------------+---------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
unaccent | 1.0 | public | text search dictionary that removes accents
(2 rows)
jthinksearch=#
jthinksearch=> \du;
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
ubuntu | | …Run Code Online (Sandbox Code Playgroud) 我刚刚在opensrc库代码中遇到一个错误,该代码分配了一个大缓冲区来修改大型flac文件,该错误只发生在使用Java 1.8.0_74 25.74-b02 32bit的具有3Gb内存的旧PC机上
最初我曾经只是分配一个缓冲区
ByteBuffer audioData = ByteBuffer.allocateDirect((int)(fc.size() - fc.position()));
Run Code Online (Sandbox Code Playgroud)
但有一段时间我有它
MappedByteBuffer mappedFile = fc.map(MapMode.READ_WRITE, 0, totalTargetSize);
Run Code Online (Sandbox Code Playgroud)
我(错误)的理解是映射缓冲区使用的内存少于直接缓冲区,因为整个映射缓冲区不必同时只在内存中使用的部分.但是这个答案说使用映射的字节缓冲区是一个坏主意,所以我不清楚它是如何工作的
Java Large File Upload抛出java.io.IOException:Map失败
完整的代码可以在这里看到
为什么我无法在带有Java Open Dialog的Windows 10 PC上看到网络驱动器.我注意到从IDE运行我的Java应用程序时出现问题,Open Dialog没有显示我的NAS(NetGear ReadyDuo安装在Z:驱动器上).然而,当我使用相同的JVM在同一台机器上运行IDE之外的应用程序时,它是可以的.
在这两种情况下,我在Windows 10 10.0 amd64上使用Java 1.8.0_72 25.72-b15 64位.我确定我不习惯这个问题,但不知道它什么时候开始发生.如果因为IDE而没有在IDE中显示它对我来说不是一个大问题,但是我担心IDE可能无关紧要并且潜在客户也看到了这种行为.
下面的屏幕截图显示了我在这两种情况下看到的内容
客户在Windows 10 Build 1703计算机上看到此错误,我没有得到它
他们用Java 1.8.0_111-b14得到了这个
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000076fd6adf, pid=3164, tid=0x00000000000027d4
Run Code Online (Sandbox Code Playgroud)
我让他们更新到最新版本1.8.0_131-b11,他们仍然是同样的错误.至少pc部分是同样的错误.
我认为错误是他们的机器特有的,我现在发现了一些类似的问题,但没有解决方案.
https://bugs.openjdk.java.net/browse/JDK-8178846?jql=text%20~%20%22msvcr100.dll%2B0x36adf%22
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 15063 (10.0.15063.0)
CPU:total 12 (initial active 12) (6 cores per cpu, 2 threads per core) family 6 model 45 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, clmul, ht, tsc, tscinvbit, tscinv
Memory: 4k page, physical 33488896k(26044808k free), swap 38469632k(28180956k free) …Run Code Online (Sandbox Code Playgroud) 是否可以使所有prepend附加组件的宽度相同?
即在这个屏幕截图中,我希望电子邮件,许可证密钥1和许可证密钥2的长度相同,这是可能的.
如果我没有使用附加组件并且只使用常规标签和表单网格,那么它可能是前置插件看起来比常规标签好得多.
相关的Html是
<main class="container-fluid">
<form action="/license.process" name="process" id="process" method="post">
<div class="input-group mb-2">
<div class="input-group-prepend">
<label class="input-group-text" id="licenseEmaillabel">
Email
</label>
</div>
<input type="text" name="licenseEmail" value="paultaylor@jthink.net" class="form-control" aria-describedby="licenseEmaillabel">
</div>
<div class="input-group mb-2">
<div class="input-group-prepend">
<label class="input-group-text" id="licenseKey1label">
License Key 1
</label>
</div>
<input type="text" name="licenseKey1" value="51302c021440d595c860233f136731865a12cfad2ce2cc2" class="form-control" aria-describedby="licenseKey1label">
</div>
<div class="input-group mb-2">
<div class="input-group-prepend">
<label class="input-group-text" id="licenseKey2label">
License Key 2
</label>
</div>
<input type="text" name="licenseKey2" value="1e50214376557ba3e1dede6c490f33d07b738515c8c2a03" class="form-control" aria-describedby="licenseKey2label">
</div>
<h3 class="error" style="visibility:hidden;">
</h3>
<input type="submit" name="cancel" value="Cancel" class="btn btn-outline-secondary"> …Run Code Online (Sandbox Code Playgroud) 我刚刚将我的应用程序从Java8移到了Java10,这是我现在需要添加的一部分
--add-modules java.xml.bind
避免 java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
例外.
这在我的批处理文件中工作正常
JVM64\bin\java --add-modules java.xml.bind -cp lib;lang -Xms150m -Xmx400m -jar lib/SongKong-5.7.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
Run Code Online (Sandbox Code Playgroud)
但我不能让我的等效winrun4j .ini文件工作
我试过添加
vmarg.1=--add-modules java.xml.bind
Run Code Online (Sandbox Code Playgroud)
然后试了一下
vmarg.1=--add-modules
vmarg.2=java.xml.bind
Run Code Online (Sandbox Code Playgroud)
但是没有任何效果,从winrun4j运行时我仍然得到NoClassDefFoundError
我正在使用Hibernate 4.3.11.Final和H2 1.3.172数据库,我在一个缓慢的Linux机器上分析我的应用程序,并发现它花费更多的时间在特定的SQL INSERT然后其他任何东西.似乎准备好的语句没有被缓存,因为准备好的语句的数量似乎与执行的语句数量大致相同.
我是否解释了这一点(我正在使用Yourkit Profiler)
我的HibernateUtil类配置如下
public static Configuration getInitializedConfiguration()
{
Configuration config = new Configuration();
config.setProperty(Environment.DRIVER,"org.h2.Driver");
config.setProperty(Environment.URL,"jdbc:h2:"+Db.DBFOLDER+"/"+Db.DBNAME+";FILE_LOCK=SOCKET;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;CACHE_SIZE=50000");
config.setProperty(Environment.DIALECT,"org.hibernate.dialect.H2Dialect");
System.setProperty("h2.bindAddress", InetAddress.getLoopbackAddress().getHostAddress());
config.setProperty("hibernate.connection.username","jaikoz");
config.setProperty("hibernate.connection.password","jaikoz");
config.setProperty("hibernate.c3p0.numHelperThreads","10");
config.setProperty("hibernate.c3p0.min_size","20");
//Consider that if we have lots of busy threads waiting on next stages could we possibly have alot of active
//connections.
config.setProperty("hibernate.c3p0.max_size","200");
config.setProperty("hibernate.c3p0.timeout","300");
config.setProperty("hibernate.c3p0.maxStatementsPerConnection","50");
config.setProperty("hibernate.c3p0.idle_test_period","3000");
config.setProperty("hibernate.c3p0.acquireRetryAttempts","10");
addEntitiesToConfig(config);
return config;
}
Run Code Online (Sandbox Code Playgroud)
我想知道我是否错误地配置了它,特别令人困惑的是c3po文档确实与Hibernate配置完全结合了一些参数的名称.
即它是max_size或max_pool_size
它是一个单用户多线程应用程序,理想情况下我希望在应用程序的持续时间内缓存所有准备好的语句,因为只有大约50个不同的语句.
我每次都明白这一点
session = HibernateUtil.beginTransaction();
Run Code Online (Sandbox Code Playgroud)
将从池中获取连接,如果该特定连接先前已准备好现在需要的语句,则它可以使用该预准备语句而无需编译新语句.
如果准备好的陈述不存在则准备好.
如果已经为此连接准备了五十个语句,那么最旧的语句将被删除.
占用这么多时间的这个特定查询使用如下
public static void saveMatchedToRelease(Session session,Integer reportId, Integer recNo, SongFieldKey songFieldKey, …Run Code Online (Sandbox Code Playgroud) java ×8
windows ×3
bootstrap-4 ×1
c3p0 ×1
css ×1
filesystems ×1
hibernate ×1
java-7 ×1
macos ×1
networking ×1
postgresql ×1
profiler ×1
psql ×1
recycle-bin ×1
thread-dump ×1
tomcat ×1
tomcat7 ×1
windows-10 ×1
winrun4j ×1