Compiling and running java application using powershell

梦想的初衷 提交于 2019-12-03 00:43:31

Setup environment variables in your system.

set JAVA_HOME to C:\Program Files\jdk1.7

add to PATH variable the string %JAVA_HOME%\bin

open new cmd session.

navigate your java source folder.

use javac to compile your java files.

UPDATE:

also if you are experiencing difficulities upon launching an executable via PowerShell check this Microsoft TechNet article

To answer it in a much simpler way , its the path problem .

You probably not have set env variables that's it.

This is how you should set it:

JAVA_HOME: C:\jdk1.6.0;

PATH: C:\jdk1.6.0\bin;.;

CLASSPATH: C:\jdk1.6.0\lib;.;

And later if you open a cmd prompt and type java -version , if you are able to see the java installed version then you are good to go.

Marty Wiedmeyer

The variables you speak of do not exist in PowerShell as you name them.

The correct variable names are

$Env:JAVA_HOME: C:\jdk1.6.0;

$Env:PATH: C:\jdk1.6.0\bin;.;

$Env:CLASSPATH: C:\jdk1.6.0\lib;.;

As they all must be defined in the ENV: PSDrive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!