Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Could not locate compiled file

  Asked By: Arnold    Date: Jul 10    Category: Java    Views: 737
  

My program was running successfully previously.
Few days ago I observed that program does not run at
all on Dos Prompt even if it compile successfully
coammand c:jdk1.2\bin> java <filename>

These programs are running on other computer
But in my computer the message appeared
NoClassDefFound
I have set all the path necessary. But even this
they are not running

Perhaps Java could not locate my compiled file (program)

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Allan Bailey     Answered On: Jul 10

Did you run  the code as:

java ClassName

Or

java ClassName.class


The first form is the correct form. If you append .class it will not find your
class. Perhaps you can give some more
details if this is not the case. Stack traces, the command you used to execute
your code, etc. is always helpful.

 
Answer #2    Answered By: Baylen Smith     Answered On: Jul 10

Please tell me about
stack traces
my program  was runned by using visualcafe
i have not using .class extension.
as i have already gone through a number of
books and created a few program
which was running  fine previously

 
Answer #3    Answered By: Lughaidh Fischer     Answered On: Jul 10

A stack trace occurs when you catch an exception and execute the
Exception's printStackTrace() method. A stack trace may also occur if a
RuntimeException is propagated all the way up to the VM.

In order to know more about your problem, can you post the command you
are issuing as well as the error which occurs.

 
Answer #4    Answered By: Aalia Arain     Answered On: Jul 10

What you are saying is right in my case.
My program  is now running

In one program I want to run  Dos Command
e.g. copy f1.jpg to f2.jpg
from the java  by process and runtime method
but it is not running  and
it shows error stack trace is disable

 
Answer #5    Answered By: Terence Mitchell     Answered On: Jul 10

You can use command line commands from withing Java using the
Runtime.exec() method, but you should try to avoid it at all costs. The
main reason to avoid it is because it makes your application much less
portable. You should try instead to use the functionality in the Java
API or extend it to provide this functionality.

For example, if you want to copy one file  to another in Java you could
do something like:

FileInputStream in = new FileInputStream("filename1");
FileOutputStream out = new FileOutputStream("filename2");

int b = -1;
while((b = in.read()) != -1){
out.write(b);
}

out.close();
in.close();


You can do a lot to make this better though, such as buffering your
input and output data, checking to see if files exist before reading and
writing, catching exceptions, etc.

 
Didn't find what you were looking for? Find more on Could not locate compiled file Or get search suggestion and latest updates.




Tagged: