Question:
Java. How can I compile and link multiple files with command line ?
anonymous
2011-06-09 07:02:14 UTC
So, I'm a noob.
I have all my files in one directory.
I type, "javac *.java" to compile, no error.
Then, I type "java Main" (assuming that's what I'm supposed to do). At this point, it tells me :
"an error occurred : Class mypackage.Main not found in CLASSPATH C:\Java\lib\classes.jar".

Help me please !
Three answers:
AnalProgrammer
2011-06-09 07:11:01 UTC
Use this link to find the answer.



Have fun.
deonejuan
2011-06-09 07:21:39 UTC
javac makes the .class files not the .jar



If your files are in a directory on desktop, you will have to navigate into that folder. On Windoze7 it might be something like...



\\\\C:\\windows \users \billybob \Desktop \users \test



so you would type in the command prompt...

> $ cd \\\\C:\windows\users\billybob\Desktop\users\test



and then, Windoze makes note that CWD -- Current Working Directory is where to find files for the next dos-command.



Windoze7 is a drug-induced nightmare for software dev trying to use command-prompt. You will make better progress and live longer if you install an IDE, such as NetBeans.



On the NT platform I used to make a folder for java files and also a pair of .bat file. The first .bat was java.bat

javac *.java



the 2nd .bat was Main.bat

java Main



A dbl-click on either one of the .bat files inside the folder of source code makes the cmmd-prompt cd command unnecessary because you launch from the CWD.
?
2016-11-09 12:37:26 UTC
unusual. For me it works effective under domicile windows. as long as each and every type is defined in a source report of the comparable call, javac will discover it. you would be able to additionally do "javac packagename/*.java" assuming all your java archives are in a folder observed as "packagename".


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