| | |
Compiling a PACKAGE using javac
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 14
Reputation:
Solved Threads: 0
I wrote a Java program, and it successfully compiles and runs in NetBeans, but I'm not able to do the same in the command line, on Windows XP.
It works ok with 1 class, but when I have few files 'package' I have a problems.
1.Start -> run -> cmd
2.Go to dir:
3.Now I'm trying to compile a package:
(my package is this:
I do compile my package:
Then I try to run compiled package:
Also trying:
But allways is errors only:
===============
Source codes
------------
If I have only one file(class), then all is ok:
So how I can build the Java package in command line.
It works ok with 1 class, but when I have few files 'package' I have a problems.
1.Start -> run -> cmd
2.Go to dir:
cd C:\Program Files\Java\jdk1.6.0_16\bin3.Now I'm trying to compile a package:
(my package is this:
Java Syntax (Toggle Plain Text)
test/Main.java test/Hotel.java
I do compile my package:
javac test\*.javaThen I try to run compiled package:
java test\Mainjava testBut allways is errors only:
Java Syntax (Toggle Plain Text)
C:\Program Files\Java\jdk1.6.0_16\bin>java test\Main Exception in thread "main" java.lang.NoClassDefFoundError: test\Main/class Caused by: java.lang.ClassNotFoundException: test\Main.class at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: test\Main.class. Program will exit.
===============
Source codes
JAVA Syntax (Toggle Plain Text)
package test; public class Main { static int SPEED = 300; // ms public static void main(String[] args) { // TODO code application logic here System.out.println("Loading"); // Run hotels'live Hotel.do_live(SPEED); } }
JAVA Syntax (Toggle Plain Text)
package test; public class Hotel { public static void do_live(int wait) { System.out.println("\n\rHotel was finished"); } }
------------
If I have only one file(class), then all is ok:
Java Syntax (Toggle Plain Text)
javac TestJava.java java TestJava
So how I can build the Java package in command line.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- hi, renewd member needs help (Java)
- I'm starter (Java)
- Compiling (Java)
- Im really close but need help (Java)
- Another "cannot find symbol" compiling error (Java)
- Newbi can anyone help with methods and classes (Java)
- Compiling And Running (Java)
- Problems with compiling (Java)
- Samba browser (OS X)
Other Threads in the Java Forum
- Previous Thread: no-Cache Control in I.E causing back browser to show page not found
- Next Thread: prefix,Postfix Notations
Views: 445 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation binary bluetooth businessintelligence card chat class classes client code collision component crashcourse database draw eclipse ee error event exception file fractal free game gis givemetehcodez graphics gui helpwithhomework html ide image input integer integration j2me java javadoc javafx javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile netbeans newbie nls number object oracle physics print problem program programming project radio recursion scanner screen security server service set size sms socket software sort sql string swing test textfield threads time transfer tree trolltech utility windows






