New Posts  All Forums:Forum Nav:

Running Java in CMD

post #1 of 5
Thread Starter 
I'm doing a homework assignment where I wrote two classes of code. It basically is suppose to mimic a UDP client and server socket. The code compiles fine. The only problem is the book says
Quote:
To test the application, you install and compile UDPClient.java in one host and UDPServer.java in another host. (Be sure to include the proper hostname of the server in UDPClient.java) Then execute the two programs on their respective hosts.

How exactly would I do that? The professor wasn't clear and said because programming is a preq for this class you should know how to do this even though I came from another school and we never did programming on the network level.

The IP address in the client code to the server was originally "hostname" but I changed it to a loop back address 127.0.0.0. Is it possible to get this to run on only one machine? I tried to use blueJ since that's the compiler I was taught on. I ran two instances of blueJ one running the Server class and one running the Client class. All it does is run, I don't get any type of pop ups or anything as i should stated in the code here:

System.out.println("FROM SERVER:" + modifiedSentence);

Here is the link to the zip file.

I'm assuming I have to run this from CMD with "java filename but when I do I get: "Could not load or find main class UDPServer.java/UDPClient"
Edited by matty0610 - 2/10/12 at 7:16am
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
post #2 of 5
Thread Starter 
Ok I just got it to sorta work. This is my new error in CMD.

C:\Users\Admin\Desktop\UDP Socket\UDP Socket\UDPSocket\UDP>java UPDServer
Exception in thread "main" java.lang.NoClassDefFoundError: UPDServer
Caused by: java.lang.ClassNotFoundException: UPDServer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: UPDServer. Program will exit.

C:\Users\Admin\Desktop\UDP Socket\UDP Socket\UDPSocket\UDP>javac UPDServer
error: Class names, 'UPDServer', are only accepted if annotation processing is e
xplicitly requested
1 error

video of my error http://tinypic.com/player.php?v=9jkidu&s=5
Edited by matty0610 - 2/10/12 at 12:55pm
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
post #3 of 5
Quote:
Originally Posted by matty0610 View Post

Quote:
To test the application, you install and compile UDPClient.java in one host and UDPServer.java in another host. (Be sure to include the proper hostname of the server in UDPClient.java) Then execute the two programs on their respective hosts.
How exactly would I do that? The professor wasn't clear and said because programming is a preq for this class you should know how to do this even though I came from another school and we never did programming on the network level.
The IP address in the client code to the server was originally "hostname" but I changed it to a loop back address 127.0.0.0. Is it possible to get this to run on only one machine?

i think the idea is to run the programs from separate computers. instead of using a loopback address, use the hostname of the the server computer.

i remember doing a networking lab similar to this. i ssh'd into 2 different university lab computers. i executed the client code on the first, and the server code on the second.

hope this helps you.
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #4 of 5
"Exception in thread "main" java.lang.NoClassDefFoundError: UPDServer"

That usually means your classpath is not properly defined.

What does -- echo %CLASSPATH% -- look like?
Oryx
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Haswell 4770K MSI Z87-GD65 ASUS Strix GTX 1080 Crucial Ballistix Tactical LP 16GB DDR3-1600 
Hard DriveOptical DriveCoolingOS
Crucial MX100 Pioneer 15x SATA Internal BD/DVD/CD Burner -- B... Corsair H100i Windows 10 Home 64-bit 
MonitorKeyboardPowerCase
Dell U3011 Corsair RGB K65 Cherry MX Brown Corsair AX650 Corsair 600T 
MouseMouse Pad
Logitech G500 Steelseries Glass 
  hide details  
Reply
Oryx
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Haswell 4770K MSI Z87-GD65 ASUS Strix GTX 1080 Crucial Ballistix Tactical LP 16GB DDR3-1600 
Hard DriveOptical DriveCoolingOS
Crucial MX100 Pioneer 15x SATA Internal BD/DVD/CD Burner -- B... Corsair H100i Windows 10 Home 64-bit 
MonitorKeyboardPowerCase
Dell U3011 Corsair RGB K65 Cherry MX Brown Corsair AX650 Corsair 600T 
MouseMouse Pad
Logitech G500 Steelseries Glass 
  hide details  
Reply
post #5 of 5
Thread Starter 
I actually figured it out on by chance. Turns out that since I compiled it on my laptop and then moved it to my desktop without recompiling, it kept the file path on from my laptop when i actually read the first line error. The fact that it was broken up threw me off. So I had to recompile and a new folder on my desktop and now it works. Thanks.

I was able to get it to run on one computer, had to open up two CMDs each one running a different class.
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
My System
(14 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 2700k Asus p8z68v-lx Intel HD graphics 3000 G.Skill 2x4GB DDR 3 1600 
Hard DriveHard DriveOptical DriveOS
320 GB WD Blue  1TB WD Black Samsung SH232 Win 7 Ultimate x64 
MonitorPowerCase
Samsung P2770 1920x1080 Thermal Take 600 Watt Antec 900 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming