How to run a Java program from the command line on Windows

0 votes
I'm not sure how to execute the program? Is this possible on Windows?

 Why is it different than another environment?

Thanx in advanced!!
Apr 9, 2020 in Java by kartik
• 37,520 points
961 views

1 answer to this question.

0 votes

Hello @kartik,

In case your Java class is in some package. Suppose your Java class named ABC.java is present in com.hello.programs, then you need to run it with the package name.

Compile it in the usual way:

C:\SimpleJavaProject\src\com\hello\programs > javac ABC.java

But to run it, you need to give the package name and then your java class name:

C:\SimpleJavaProject\src > java com.hello.programs.ABC

Hope this work!!

Thanks in advanced!!

answered Apr 9, 2020 by Niroj
• 82,880 points

Related Questions In Java

0 votes
1 answer

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

  Let's say your file is in C:\myprogram\ Run ...READ MORE

answered Apr 18, 2018 in Java by sophia
• 1,400 points
2,639 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

answered Apr 19, 2018 in Java by Rishabh
• 3,620 points
1,152 views
0 votes
1 answer

How to read text files from the Classpath in Java?

InputStream in = this.getClass().getClassLoader().getResourceAsStream("TextFile.txt"); InputStream in = this.getClass().getResourceAsStream("/TextFile.txt"); package ...READ MORE

answered May 8, 2018 in Java by Akrati
• 3,190 points
2,800 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by Parth
• 4,640 points
1,881 views
0 votes
1 answer

What are the prerequisites to learn Hadoop in java perspective?

In my day job, I've just spent ...READ MORE

answered Oct 11, 2018 in Big Data Hadoop by Frankie
• 9,830 points
761 views
0 votes
1 answer

How is inheritance in C++ different than that in Java?

The purpose of inheritance is same for ...READ MORE

answered Feb 6, 2019 in Java by Priyaj
• 58,100 points
961 views
0 votes
1 answer

What is the reason for no ConcurrentHashSet against ConcurrentHashMap?

Hello, There's no built in type for ConcurrentHashSet because you ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,880 points
1,436 views
0 votes
1 answer

How to pass an object from one activity to another on Android?

Hello @kartik, Implement your class with Serializable. Let's ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,880 points
754 views
0 votes
1 answer

How to run a .java file from command line passing arguments in Maven?

Hello @kartik, You could run: mvn exec:exec -Dexec.args="arg1". This will ...READ MORE

answered Jun 3, 2020 in Java by Niroj
• 82,880 points
21,051 views
0 votes
1 answer

How to get the windows native look in Java GUI programming?

Hello Kartik,  You can try the syntax: UIManager.setLookAndFeel(PLAF); (Pluggable ...READ MORE

answered May 7, 2020 in Java by Niroj
• 82,880 points
1,089 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP