Computers & Internet Logo

Related Topics:

Question about Sun Java Programming Language (cdj-275)

5 Answers

Can anyone tell how run java program in cmd prompt???

Posted by parikshityeo on

×

Ad

5 Answers

Anonymous

  • Level 1:

    An expert who has achieved level 1.

    Habit-Forming:

    Visited the website for 3 consecutive days.

    Welcome Back:

    Visited the website for 2 consecutive days.

    Mayor:

    An expert whose answer got voted for 2 times.

  • Contributor
  • 3 Answers

Hi,

You need to type:

If it's a program.class

java program

or of it's a program.jar

java -jar program.jar

regards

Posted on Apr 07, 2009

Ad

Avinash Verma

  • Level 1:

    An expert who has achieved level 1.

    MVP:

    An expert that got 5 achievements.

    Habit-Forming:

    Visited the website for 3 consecutive days.

    New Friend:

    An expert that has 1 follower.

  • Contributor
  • 11 Answers
Ad

MohanrajN

  • Level 1:

    An expert who has achieved level 1.

    New Friend:

    An expert that has 1 follower.

    Corporal:

    An expert that has over 10 points.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 11 Answers

1. Make sure that java is set in environment variable so that you can run java from anywhere
2. open command prompt type javac test.java this generates class files
3. then type java test this executes the program and give the output

Posted on Jan 01, 2015

Mishan Kasiparsad

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Sergeant:

    An expert that has over 500 points.

  • Expert
  • 175 Answers

First compile the code:
javac MyCode.java
this will take the MyCode.java file and compile it into MyCode.class
You then run/execute the file with:
java MyCode

Posted on Jul 16, 2013

Anonymous

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Governor:

    An expert whose answer got voted for 20 times.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 136 Answers

Prior to running your Java code you need to compile the code which produces the .class file, so to compile the java code on command prompt type -

javac filename.java

and to run the file type -

java filename

this will run the program that was successfully compiled

Posted on Jun 23, 2009

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

Java isn't working

try this uninstall java everything not ony what windows add and remove takes.look in C:\remove it all.now install new java.
0helpful
1answer

Java

Did your main page has a same name as java?
Or
You are running in cmd then
javac A.java // this will compile
run like:::::
java A
Any other query then tell me..........
0helpful
1answer

Java Vitual Machine Launcher prompts this message "Could not find the main class. Program will exit" How can I solve this problem? I need urgent assistance.

You need to compile the .java file you have, and run the .class file that is produced.
Open up command prompt, go to your working directory. If your file was called Hello.java: In command prompt type "javac Hello.java". Now, in the working directory, you will see a new file, Hello.class. Run that file by "java Hello.class". Hope this helps!
Thanks for using FixYa
2helpful
1answer

Cannot play games (example big fish games) after being downloaded to my pc. I get this message d3derr_notavailable

Your graphics card most likely doesn't support Direct 3D. You can test using the following command in a cmd prompt window dxdiag

In XP click start/run and type cmd in the run box to open a command prompt window.

In Vista/Win7 to open the command prompt, either go through the start menu - click start, All Programs, Accessories, then click on Command Prompt or in the run box type: cmd .
0helpful
1answer

Blue screen and freezes randomly

There could be hard disk errors that need to be fixed, or there could be files in your OS that are missing. First you should login to an account that has administrator privileges and go to Start, select Run and in the Run window type CMD and then hit enter to bring up your command prompt. If you're using Vista or Windows 7, go to the Start Orb and type CMD into the search bar, then right+click CMD and pick "Run as Administrator." Now, in the command prompt, type SFC /SCANNOW and hit enter. If you're missing any files you will be prompted to insert your Windows disc, it is quite possible that you don't have one, but the main reason you're doing this is to see if you're missing OS files because if you are then that will immediately explain the blue screens and freezes because parts of your Operating System are gone. Anyway, it will prompt you for a specific disc, if you don't have it and you don't know anyone who has it then you can't complete the scan, so stop/cancel it and run it again when you get the CD. For now though, let's work with what we have. We want to see if your harddrive is damaged. In command prompt type CHKDSK /R this will scan your harddrive for errors and repair them on the next reboot (this scan will take at least 40min). After all of that, you should run a PC/Registry optimizer such as Glary Utilities http://www.glaryutilities.com/ (I prefer this one because it's free and simple to use. Tell it to scan after you install it and then tell it to repair the issues it finds.
Scanning with an anti-malware program, an anti-rootkit program, and an anti-spyware program certainly won't hurt anything. The 3 free programs I use are

http://www.malwarebytes.org/ -- Anti-Malware
http://www.sophos.com/products/free-tools/sophos-anti-rootkit.html -- Anti-Rootkit
http://www.superantispyware.com/ -- Anti-spyware
If you don't have any antivirus program installed, Avast! http://www.avast.com/lp-upgrade-4-5-free# Is a great one, but it does not work well at all with other anti-virus programs, so don't install it if you have another anti-virus program (such as Norton Antivirus, Panda Anti-virus) running.

Hope this helps!
0helpful
1answer

I just purchased my 2nd Asus My Pal A626 Pocket PC. And I cannot run the setup program on any of my 5 computers. It tells me I need Flash 8.x or higher and I have Flash 10.x or it says I may have a...

Hi,

Go to a command prompt (CMD) by navigatinf to START->RUN and typing CMD In the command prompt, type Type c:\Program Files\Common Files\InstallShield\Driver\8\Intel 32\IDriver.exe -Embedding Then run your setup.exe or install.exe of the prog you are trying to install...

If this doesnt run, think there must virus infection in all your system...

Does any other setup files runs in your system?

Please leave these details as comment and we will provide further assistance
Rnj VINODKUMAR
0helpful
1answer

Jnlp code for the java program

From command prompt: You can also launch an application from a command prompt by typing javaws jnlp_url where jnlp_url is a url to the jnlp file of the application. Go to Start > Run > type "cmd". A command prompt window will appear. Type "javaws url_of_jnlp"
1helpful
2answers

How to run java code in cmd prompt...

javac filename.java to compile and java filename to execute
Not finding what you are looking for?

1,026 views

Ask a Question

Usually answered in minutes!

Top Sun Computers & Internet Experts

Rob Hill
Rob Hill

Level 3 Expert

1465 Answers

Muzahura Frank

Level 3 Expert

2071 Answers

Narseman

Level 3 Expert

1088 Answers

Are you a Sun Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...