My Java program is failing to run in command prompt and no result is produced.I am currently using windows 8 and I have changed my Environmental variable to C:\Windows\system32;C:\Program files\Java\jdk\bin.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
My Java program is failing to run in command prompt and no result is produced.I am currently using windows 8 and I have changed my Environmental variable to C:\Windows\system32;C:\Program files\Java\jdk\bin.
What error do you get? What code are you trying to run?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
public class MyFirstJavaProgram{
public static void main(String[]args){
System.out.printIn("Hello World");
}
}
When I click enter to run,nothing is happening
What error did you get when you try to run the program.
Tjones787
What conmmands did you use to compile and run?
No error but simply its not producing the output hello world.When I press enter the cursor moves to the next line
System.out.printIn != System.out.println()
Upper-case I != lower-case l.
That should generate a compiler error. What IDE are you using? I *highly* suggest using the command line to compile your code until you have a better understanding of what's going on.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
I used C:\'javac MyFirstJavaProgram.java'
and then C:\'java MyFirstJavaProgram'
If you are running this program from command prompt, please can you type commands "javac" and "java" and check if its showing some output?
Thanks and regards,
Sambit Swain
You need to post the full text of your command prompt, starting with the javac command. Just copy any paste it here.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
okay I wil try this.I am using jdk 1.6.0_35
--- Update ---
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Attache Students>C:\'javac MyFirstJavaProgram.java'
'C:\'javac' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Attache Students>
Now its failing to recognize javac
You need to make sure your jdk bin is on your path. Recommended reading: Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
okay Kevin thanks
As per the above comment by KevinWorkman, if path is set correctly then you java program will execute successfully. Post here if you find any further issues.
Thanks and regards,
Sambit Swain
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Sorry, I missed that. it has to println() method and import is missing.
Thanks and regards,
Sambit Swain
There is no import missing.
Yes, import statements are not required for this.
Thanks and regards,
Sambit Swain
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Leave off the "C:\". That tells the OS to look in the C:\ folder for the javac command.C:\Users\Attache Students>C:\'javac MyFirstJavaProgram.java'
If the bin folder is on the PATH, you should be able to enter javac without a path:
C:\Users\Attache Students>javac MyFirstJavaProgram.java
If you don't understand my answer, don't ignore it, ask a question.
KevinWorkman (January 23rd, 2014)
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
there is problem with ur java,,
just open command prompt and
set path of your bin
i know it wont make any change as you have added the path to envt. variable .. but just check..
if the same error proccedes i suggest you to use netbeans.
I think its now working.I have opened blue j and its running after I have installed a new jdk
--- Update ---
import java.io.*;
public class DeductionRecords{
string DeductionRecords="DED";
string Transactiontype;
static final short ADCODE=4360;
string Payeecode;
double Amountincents;
public DEDUCTION RECORDS(string name){
this.name=name;
}
//Assign payee code to variable payee code
public void recpayeecode (String recpayeecode){
payeecode=recpayeecode;
}
/*Assign Amount in cents to variable amount in cents*/
public void recamountincents(double recamountincents){
amountincents=recamountincents;
}
/*Assign policy ref number to variable policy ref number*/
public void recpolicyrefnumber(string policyrefnumber){
policyrefnumber=recpolicyrefnumber;
}
//Print the deduction records details
public void print DeductionRecords(){
system.out.printIn("name:"+name);
system.out.printIn("ec number:"+ec number)
system.out.printIn("Transaction type:+Transaction type)
system.out.printIn("AD CODE:+AD CODE)
system.out.printIn("payee code:"+payee code)
system.out.printIn("policy ref number:+policy ref number)
system.out.printIn("From date:"+From date)
system.out.printIn("To date:"+To date)
system.out.printIn("Amount in cents:"=amount in cents)
}
}
My code is failing to compile on line 23 where its written public void print DeductionRecords(){
I am using Blue J.May you examine my code
--- Update ---
import java.io.*;
public class DeductionRecords{
string DeductionRecords="DED";
string Transactiontype;
static final short ADCODE=4360;
string Payeecode;
double Amountincents;
public DEDUCTION RECORDS(string name){
this.name=name;
}
//Assign payee code to variable payee code
public void recpayeecode (String recpayeecode){
payeecode=recpayeecode;
}
/*Assign Amount in cents to variable amount in cents*/
public void recamountincents(double recamountincents){
amountincents=recamountincents;
}
/*Assign policy ref number to variable policy ref number*/
public void recpolicyrefnumber(string policyrefnumber){
policyrefnumber=recpolicyrefnumber;
}
//Print the deduction records details
public void print DeductionRecords(){
system.out.printIn("name:"+name);
system.out.printIn("ec number:"+ec number)
system.out.printIn("Transaction type:+Transaction type)
system.out.printIn("AD CODE:+AD CODE)
system.out.printIn("payee code:"+payee code)
system.out.printIn("policy ref number:+policy ref number)
system.out.printIn("From date:"+From date)
system.out.printIn("To date:"+To date)
system.out.printIn("Amount in cents:"=amount in cents)
}
}
My code is failing to compile on line 23 where its written public void print DeductionRecords(){
I am using Blue J.May you examine my code
If you check the compilation error, you can easily understand the issue. Check the syntax of method defination..
Thanks and regards,
Sambit Swain