Is it possible to run a java program from command line on windows?How?

0 votes

I'm trying to execute a Java program from the command line in Windows. Is this possible? Any help? Thanx

Apr 18, 2018 in Java by Daisy
• 8,040 points
105 views

1 answer to this question.

0 votes

  Let's say your file is in C:\myprogram\

Run Command Prompt (Windows+R)

C:\> cd \myprogram

This makes C:\myprogram the current directory.

C:\myprogram> dir

This displays the directory contents. You should see filenamehere.java among the files.

C:\myprogram> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin

This tells the system where to find JDK programs.

C:\myprogram> javac filenamehere.java

This runs javac.exe, the compiler. You should see nothing but the next system prompt...

C:\myprogram> dir

javac has created the filenamehere.class file. You should see filenamehere.java and filenamehere.class among the files.

C:\myprogram> java filenamehere

This runs the Java interpreter. You should then see your program output.

If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!  

answered Apr 18, 2018 by sophia
• 1,400 points

Related Questions In Java

0 votes
1 answer

Is it possible to create a memory leak with Java

Here's a good way to create a memory ...READ MORE

answered May 30, 2018 in Java by parth295
• 4,600 points
150 views
0 votes
1 answer
0 votes
3 answers

Is it possible to take char input from scanner?

// Use a BufferedReader to read characters ...READ MORE

answered Sep 7, 2018 in Java by Daisy
• 8,040 points
1,031 views
0 votes
1 answer

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

answered May 24, 2018 in Java by Rishabh
• 3,540 points
35 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,380 points

edited Nov 6, 2018 by Omkar 7,105 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,799 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
4,700 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
407 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,850 points
76 views
0 votes
1 answer

What is ?: this operator called in java ? how dose it function?

? :  is the Conditional operator and is ...READ MORE

answered Jun 11, 2018 in Java by sophia
• 1,400 points
56 views