Hi, I made a little Java program with Netbeans, and it works with no problem.
When trying to compile it with Eclipse I had to move some files(don't remember now) to make it work, otherwise Eclipse give me some errors.
So this is my problem: when trying to compile the program with Textpad it gives me some errors ( cannot find xx, cannot find xxx ...) and the program won't start. I tried to use the same method used with Eclipse, but I didn't succeed.
So, do you know if Netbeans writes some code parts in another file, or something else? Is it a known problem? Can you help me to make the program running also with Textpad?
If necessary I can send you my source files.
Thanks, bye
Netbeans and Eclipse ok, Textpad not...
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Both Eclipse and Netbeans are IDEs and they're main job is compiling java code. Both use their own compiler and know where to look for class libraries, without the need for you to tell them.
Textpad on the other hand is only a text editor and relies on an external tool (the javac compiler) to compile java code. You need to tell the compiler where to look for java classes, unless they can be found in the default places.
All the gory details can be found here and here. An brief tutorial on how to start writing java programs is here.
If you're starting with java it would be a good idea to first familiarize with the command line tools and only after that start using an IDE.
Textpad on the other hand is only a text editor and relies on an external tool (the javac compiler) to compile java code. You need to tell the compiler where to look for java classes, unless they can be found in the default places.
All the gory details can be found here and here. An brief tutorial on how to start writing java programs is here.
If you're starting with java it would be a good idea to first familiarize with the command line tools and only after that start using an IDE.
Thanks agnul, I followed your instructions and read the documentation, but it still gives me errors.
All my .java files are in this path:
C:\Eclipse Workspace\proj\src\test
So I used this command in cmd.exe:
javac -classpath C:\Eclipse Workspace\proj\src\test *.java
The command line noticed me some warnings for deprecated APIs, but I think this isn't the problem, right?
Then in command line I wrote:
java Autonoleggio (<-- this is the main java file)
But it gives the errors you see in this image:
So, how do I solve it?
Then, it generates a lot of .class files for the same java file(Autonoleggio.class, Autonoleggio$1.class, ... , Autonoleggio$11.class) . Is it normal?
All my .java files are in this path:
C:\Eclipse Workspace\proj\src\test
So I used this command in cmd.exe:
javac -classpath C:\Eclipse Workspace\proj\src\test *.java
The command line noticed me some warnings for deprecated APIs, but I think this isn't the problem, right?
Then in command line I wrote:
java Autonoleggio (<-- this is the main java file)
But it gives the errors you see in this image:
So, how do I solve it?
Then, it generates a lot of .class files for the same java file(Autonoleggio.class, Autonoleggio$1.class, ... , Autonoleggio$11.class) . Is it normal?
Looking at your screenshot a couple of things come to mind
if all the classes and libraries are in your current working dir you don't need to specify a -classpath option (unless you changed the default classpath)
if you specify the -classpath option it should always include the current working directory, so add ".;" at the beginning
if you give the -classpath option to javac you should give the same option to java
as for your error... the error message says "wrong name", and the screenshot suggests Autonoleggio is inside the "test" package, so your classpath should point to ".....\src", and you should run the class doing something like "java test.Autonoleggio".
The Autonoleggio$1..11 class files are generated for the anonymous inner classes you have in Autonoleggio.java
if all the classes and libraries are in your current working dir you don't need to specify a -classpath option (unless you changed the default classpath)
if you specify the -classpath option it should always include the current working directory, so add ".;" at the beginning
if you give the -classpath option to javac you should give the same option to java
as for your error... the error message says "wrong name", and the screenshot suggests Autonoleggio is inside the "test" package, so your classpath should point to ".....\src", and you should run the class doing something like "java test.Autonoleggio".
The Autonoleggio$1..11 class files are generated for the anonymous inner classes you have in Autonoleggio.java
No, you didn't.I followed your suggestions.Now new errors...
javac is the compiler. You pass file names as arguments to the compiler, and those filenames should have the .java extension.
java is the interpreter. You pass class names as arguments to the interpreter. Class names don't have any extension.
The interpreter is telling you that it cannot find a class named "java" inside the package "Autonoleggio", and it's telling you that because you gave it a file name instead of a class name. Why should the interpreter look for a class named "java" inside a package named "Autonoleggio"? Because in class names "." is used as the package separator.
What I tould you instead is that your "Autonoleggio" class probably lives in the "test" package, so the interpreter expects the class name to be test.Autonoleggio
Go back to my first answer, re-read all the links and then read the tutorial lesson on packages also. Then read all of them again.