我需要在 Java 中获取 JAVA_HOME 和 CATALINA_HOME 环境变量的值。我正在运行一个 JAR(不是 WAR)并且在System.getProperties()我只能找到"java.home".
我在这里阅读了一些关于它的其他问题,尝试了它们,但无法使它们起作用 - 我得到了不同的例外或null结果只是价值。
我记得多年前使用JNA做过类似的事情,但那是在 Windows 的 16 位时代。我能找到的最新JNA jar 是 2011 年的,在 intelliJ 工作中运行它,但是当我在 maven 中进行构建时,我会收到关于找不到某些类的错误。
我将继续调查JNA 的方向,很高兴收到任何帮助和/或想法。我认为我只是缺少正确的Maven 依赖项。
到目前为止,这是我班级的源代码:
// C:\devtools\java-external-jars\jna-4.2.2\jna-platform-4.2.2.jar
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.WinReg;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.prefs.Preferences;
public class WinRegistryHelper {
public static final String SYSTEM_ENVIRONMENT_KEY_PATH = "SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment"; …Run Code Online (Sandbox Code Playgroud) 我是 AngularJS 的新手,刚刚开始在线课程。
我正在尝试在运行 Windows 7 的计算机上安装 angular CLI。我以管理员身份打开命令行并运行npm install -g @angular/cli. 安装开始,几分钟后我收到一个错误:

I see the notification "operation not permitted", but I am the administrator of the computer and the command line I run as administrator.
What am I doing wrong? The same installation I did on my laptop at home and it was successful.
I am checking with our IT support about other possible causes and will appreciate any help.
This is not a duplicate of Fail …
我从一个普通的 Java EE 应用程序转移到 quarkus.io。在 Java EE 中,我有一个属性文件,
version=${project.version}并在 JAX RS 端点中读取此文件。这非常有效。
@GET
public Response getVersion() throws IOException {
InputStream in = getClass().getClassLoader().getResourceAsStream("buildInfo.properties");
if (in == null) {
return Response.noContent().build();
}
Properties props = new Properties();
props.load(in);
JsonObjectBuilder propertiesBuilder = Json.createObjectBuilder();
props.forEach((key, value) -> propertiesBuilder.add(key.toString(), value.toString()));
return Response.ok(propertiesBuilder.build()).build();
}
Run Code Online (Sandbox Code Playgroud)
现在我在用quarkus和MicroProfile,不知道有没有更好的方法。
我使用 MicroProfile 的 ConfigProperty 设置进行了尝试。
@ConfigProperty(name = "version")
public String version;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Property project.version not found.
这是我的 pom 的构建部分。
<build>
<finalName>quarkus</finalName>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>1.0.0.CR2</version>
<executions>
<execution> …Run Code Online (Sandbox Code Playgroud) I want to convert 1574348400 value to date format using code:
public class Main {
public Main() {
long value = 1574348400;
String dateString = new SimpleDateFormat("EEEE dd MMMM, yyyy").format(new Date(value));
System.out.println("Formated time: " + dateString);
}
public static void main(String[] args) {
new Main();
}
}
Run Code Online (Sandbox Code Playgroud)
I want to get the output as: Wednesday 20 November, 2019 but I'm getting Monday 19 January, 1970. How to get the current date not the 1970's date?
我的任务是将用 VB6 编写的应用程序的某些部分进行代码转换为 Java。现在,我有两个问题,第一是我从来没有做过这样的事情,所以我缺乏经验,第二是我以前从未使用过VB6。
我花了一些时间在谷歌上搜索并阅读不同的帖子,但我找不到任何有用的东西,所以这是我最后的机会。
你知道有什么工具、转换器可以帮助我解决这个问题吗?如果您以前做过类似的事情,您能给我一些关于如何处理这个问题的建议吗?
java ×3
angular ×1
angular-cli ×1
converters ×1
date ×1
java-home ×1
jna ×1
microprofile ×1
node.js ×1
npm-install ×1
quarkus ×1
vb6 ×1