AboutArtemus Harper Expertise I have a BS in computer science and am working towards a Masters degree.
Experience I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection, and Java java.nio.*
knowledge of Java bytecode and annotations.
Basics in c++ and c#
Question QUESTION: i want to create a .bat file for my project so that i can double click on it and execute it.
i tried creating it but it didnt worked. the command prompt pops up,
i added these 2 lines
javac *.java
java SpiderControl.java
here SpiderControl has the main function.is these lines are sufficient or i am doing some mistake. kindly tell me the complete code for it.
ANSWER: The java command does not take the name of the source program as you have suggested, but rather the fully qualified class name.
E.g.
If you class was:
public class SpiderControl
{
public static void main(String[] args)
{
...
}
}
you would use:
java SpiderControl
If you had a package decleration:
package myclasses.gui;
public class SpiderControl
{
public static void main(String[] args)
{
...
}
}
Then it would be:
java mclasses.gui.SpiderControl
Also, you don't need to have javac compile all files, it will determine what to compile by simply giving your main program.
---------- FOLLOW-UP ----------
QUESTION: ok.now i tried
javac SpiderControl.java
java SpiderControl
but these 2 lines are again not working.the command window pops up but again closes whithout displaying the interface.what to do now??
Answer You might have the classpath configured incorrectly, or the batch file is not opening in the correct directory. Instead of simply double clicking the command prompt, you should open a command window, try running the batch file, and see if there is any error.
You can probably correct this, by adding a cd command to the directory where you have the compiled .class files. You can change the directory to the current bat file directory with:
cd /d %~d0%~p0
you can also add a pause command so the window pauses before exiting.
If the directory is correct, then you classpath is set to something other than the default, so you would want to change: