Question:
Java Error?
Gulliver
2007-01-30 01:36:26 UTC
Hello, I am not able to execute a java program using the "java" command. I can compile the source files and, am able to create the .class file.

But i am not able to execute the file.
Eight answers:
Desi Geek
2007-01-30 02:44:33 UTC
Friend, you have given very little data with which to diagnose your problem.



Based on the little data that you have given, I'd say that the problem is probably with the classpath (as is the case with over 95% of Java newbie problems). Look closely at how you built the .class file. I expect that you'll find a command similar to javac.exe -classpath SOME_CLASSPATH .... . The classpath argument tells the system to use some libraries found at some path in your system. You need to specify the same classpath* to your call to java.exe. (It's not the same classpath exactly; you'll have to add the path to the recently built .class files to your classpath).



Your problem is a common one, and should be well explained in the first chapter of any good book on beginning with Java programming. I've included a link to a page that may help you.



If you can post more details, such as at least giving the exact error that you are facing, I'm sure an accurate diagnosis can be done.
Sunil Saripalli
2007-01-30 09:43:35 UTC
If you have Java Run Time Environmrnt installed on your computer. You can make a html file which would include the function call to the class file you have created.



The html file you have created should call the java class file and work fine in explorer.



If you need any further clarification please get back to me,
jerome
2007-01-30 10:42:16 UTC
maybe you are running the wrong file name.

for example your filenames are::



numbers.java



you should have a class file. which is the class name of your java programs



like



ArrayRotation.class





when you compile like



javac Numbers.java



and you run



java Numbers



you will surely not be able to run it



because in java programming language..



you run the .class file



so you would want to run your program like this



java ArrayRotation



always remember that you run the .class file not the .java file



ok?
angelvein
2007-01-30 10:10:36 UTC
you must first check if your java program is a program for java or an applet for HTML..



compile the program using javac..you need first to locate the executable program javac or Java compiler..



for example, it is located in C:/>J2sdk1.4.0/bin then type in your command prompt:



C:\>cd\



C:\>cd j2sdk1.4.0\bin



C:\j2sdk1.4.0\bin>javac clsProgram.java



providing that your program was saved in .java format, NOT .txt or text.



after compiling it, type the ff:



C:\j2sdk1.4.0\bin>java clsProgram



NOTE that you do not need to include the .java file extension because after it has been compiled, it is already a class file..



..If it still is not working, try appletviewer instead of java.......



goodluck..
Mr.Sincere
2007-01-30 10:44:14 UTC
I need to know as to the exact error that is displayed whle using the command "java "
kamesh
2007-01-30 09:45:08 UTC
ur java program may be applet based one. If it is, then using appletviewer only, u can execute it.
anshu
2007-01-30 10:37:26 UTC
ur program may be in applet , for that u need appletviewer to run the program. or check ur program whether it is right.
Sumanth
2007-01-30 17:07:06 UTC
try java.com


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...