Question:
Why won't my java compiler work with *.java?
Lulu
2010-06-04 17:58:39 UTC
I'm trying to compile a folder of .java files by using the command:

javac *.java

My command prompt doesn't give me an errors, except these:

Note: BoundedGrid.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

These errors have shown up before, but have never been a problem that prevented my files to compile. When I try to run a program, it can't find it. When I compile the file separately, it gives me errors that it can't find the classes that the file uses.

Should I reinstall java? What is wrong with my compiler?
Four answers:
Light Cloud
2010-06-04 19:50:50 UTC
The other posters give good suggestions.



Just wanted to point out that your two "errors" are just warnings; as you noted, warnings don't actually stop compilation. Your code either successfully compiled or it failed. If the compilation was successful, then it should've generated the .class files. So if after typing in "javac *.java", the compiler did create the .class files, then the compiler works, and the compile was successful.



If the main method is located in Bla.java, then you should be able to run with command "java Bla". When you say "it can't find it", do you mean the command prompt can't find the "java" program, or it can't find your class files. If it can't find the java program (something like "bad command or file name"), you probably should set your PATH variable so that it looks in Java's bin directory. If "java" does work, and it's complaining that it can't find "Bla", either you're mistyping the command (such as including the ".class" in the name, which is a mistake), or your CLASSPATH variable is incorrect.



If the Java files are in another folder, you might be able to access them giving the relative path -- e.g. "java folderName/mainClass" instead of just "java mainClass"
Voice of Insanity
2010-06-04 18:12:21 UTC
To run a program you need to tell java the classpath i.e. the path to your class files using the -cp option.

e.g. java -cp c:\javafiles MyProgram



Also remember that the class name is case sensitive and don't type the .class at the end.
?
2016-10-19 10:06:38 UTC
At our school we basically switched from JBuilder to Eclipse. Its like JBuilder, yet not one in each and every of those hog. the scholars like it. we even have obtainable, for people who opt to do command line, emacs. and a few use JCreator, which i in my opinion do in comparison to for novices. Eclipse enables the person to have a drop down menu while making use of the scope operator..a attainable subject. i've got faith with lots to keep in mind, why ought to you should keep in mind the appropriate spelling of a manner and so on... All are loose downloads. books; i does not spend a dime till I knew what the instructor replaced into going to apply. I genuinely have got here upon maximum use the e book as a handbook and in no way incredibly study it. So, between the e book and the internet and sophistication, you should be effective. good success
Lie Ryan
2010-06-04 18:08:27 UTC
have you tried recompiling with:

javac -Xlint:unchecked *.java


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