MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
July
Sun Mon Tue Wed Thu Fri Sat
 
17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
2024
Months
JulAug Sep
Oct Nov Dec


Fri, Aug 05, 2022 5:01 pm

Running java from an Eclipse installation from the command line

For an introductory Java class I am taking, I installed the Eclipse integrated development environment (IDE) on a Microsoft Windows 10 system. In addition to compiling and running Java programs through the IDE, though, I wanted to compile Java programs using the Java compiler, javac.exe, and run them using java.exe from Windows' command-line interface (CLI). The installation process for Eclipse installed the javac.exe and java.exe executables in a user directory with a long directory path to those executables. Note: you should install the Eclipse IDE from the account which you wish to use to compile and run java programs. The location wasn't added to the path environment variable, so if you try to run the programs from a command prompt, you will see the following, unless you specify the full path name where the executable files are located.

C:\Users\Jim>java
'java' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Jim>javac
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Jim>

I didn't want to have to copy and paste the full path on the command line or type it in every time I wanted to use the two executables from the command line. To avoid that problem you can add the directory path to the path environment variable through a set path= command or create another environment variable, e.g., JAVA_HOME that points to the directory where the two files are located, though both methods apply only to a particular command line instance. I.e., if you close a command prompt window where you've set one of the variables to include the location where Eclipse installed java.exe and javac.exe then open another command prompt window, you will have to set the environment variable again in the new instance. An alternative way to make a permanent path change from a command prompt interface is to use the Windows setx command, though I would not recommend it, since if your path variable already has a path that is more than 1,024 characters long, setx can truncate the path to 1,024 characters, so that you not only don't get the additional directory added to the path, but you may lose some of the path setting you had prior to issuing the command. If you want to make a permanent change, see responses to the "Overcoming the 1024 character limit with setx" posting at the superuser.com site.

[More Info ]

[/languages/java/eclipse] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo