怎么用reg文件添加环境变量,下面的方法不行。请高手解答。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了怎么用reg文件添加环境变量,下面的方法不行。请高手解答。相关的知识,希望对你有一定的参考价值。
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"Path"=%path%;"C:\\Program Files"
此处虽然可以引用已经存在的环境变量,但是因为这里是在修改Path变量,所以引用自身会发生问题(但是引用其他的环境变量是可以的)
可以使用批处理解决这个问题。
将下面的代码保存为1.bat
@echo off
echo Windows Registry Editor Version 5.00>path.reg
echo [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment]>>path.reg
echo\\>>path.reg
echo "Path"="%path%;D:\\test\\" >>path.txt
(for /f "tokens=1* delims=:" %%i in ('findstr /n .* path.txt') do (
set "line=%%j"
setlocal enabledelayedexpansion
if "!line!"=="" (echo.!line!) else (
set "line=!line:\\=\\\\!"
echo.!line!
endlocal
)))>tmp.txt
move tmp.txt path.txt
type path.txt>>path.reg
del path.txt
pause
D:\\test\\是你追加的新的内容,相应修改即可
然后会得到一个path.reg双击导入注册表即可。
注意:要使修改生效,需要重启电脑。
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"Path"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
00,46,00,69,00,6c,00,65,00,73,00,5c,00,4e,00,56,00,49,00,44,00,49,00,41,00,\
20,00,43,00,6f,00,72,00,70,00,6f,00,72,00,61,00,74,00,69,00,6f,00,6e,00,5c,\
00,50,00,68,00,79,00,73,00,58,00,5c,00,43,00,6f,00,6d,00,6d,00,6f,00,6e,00,\
3b,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,3b,00,25,00,53,00,\
79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,3b,00,25,00,53,\
00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,53,00,\
79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,62,00,65,00,6d,00,3b,\
00,25,00,53,00,59,00,53,00,54,00,45,00,4d,00,52,00,4f,00,4f,00,54,00,25,00,\
5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,69,00,6e,\
00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,68,00,65,00,\
6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,5c,00,00,00追问
答非所问呀。哥们。
参考技术B 我这会儿也在进行这个,想了好几种格式都不可以docker中,jdk用镜像 怎么配置环境变量
docker中,jdk用镜像配置环境变量的方法如下:一、安装 JDK
1、首先,解压 JDK 程序包:
tar -zxf /mnt/software/jdk-7u67-linux-x64.tar.gz -C .
2、重命名 JDK 目录:
mv jdk1.7.0_67/ jdk/
二、设置环境变量
首先,编辑.bashrc文件
vi ~/.bashrc
然后,在该文件末尾添加如下配置:
export JAVA_HOME=/opt/jdk
export PATH=$PATH:$JAVA_HOME
最后,需要使用source命令,让环境变量生效:
source ~/.bashrc 参考技术A 使用Docker 进行Java 开发步骤:
1、准备工作
现在最流行的是选择Spark,它是一个基于Java 8的极小的框架。Spark使用Maven作为构建工具。
2、源代码和配置文件
在这个例子中你要增加三个文件:
Maven的配置文件: pom.xml
一个Java类:Hello.java
一个Dockerfile
例子:
hello.java:
package sparkexample;
import static spark.Spark.get;
public class Hello
public static void main(String[] args)
get("/", (req, res) ->
return "hello from sparkjava.com";
);
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hellodocker</groupId>
<artifactId>hellodocker</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>sparkexample</finalName>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>sparkexample.Hello</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>sparkexample</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>sparkexample.Hello</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Dockerfile:
FROM java:8
# Install maven
RUN apt-get update
RUN apt-get install -y maven
WORKDIR /code
# Prepare by downloading dependencies
ADD pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
# Adding source, compile and package into a fat jar
ADD src /code/src
RUN ["mvn", "package"]
EXPOSE 4567
CMD ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-jar", "target/sparkexample-jar-with-dependencies.jar"]本回答被提问者采纳
以上是关于怎么用reg文件添加环境变量,下面的方法不行。请高手解答。的主要内容,如果未能解决你的问题,请参考以下文章