Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Java-How do I actually use the JDK?
New Posts  All Forums:Forum Nav:

Java-How do I actually use the JDK?

post #1 of 8
Thread Starter 
Hey guys really dumb question here.
I've only used Visual C++ and Visual C# and when I decided to dabble in Java I realized how "green" or "naive" I actually am in software.

My question is, how exactly do I use the Java JDK? As in, if im typing up my code in notepad, How do I compile it? actually run it? In short, What am I doing with the java 6 program/thingy I just downloaded? Hopefully this can at least bring a grin to someones face lol.

hahaha This is the problem with starting out in IDE's that do pretty much everything for you short of actually typing out your code.
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
post #2 of 8
You can try out netbeans. It handles most of the compiling for you.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
1100t Asus m4A78T-E HIS 5850 4G 
Hard DriveOS
60 SS, + 3T Windows 7 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
1100t Asus m4A78T-E HIS 5850 4G 
Hard DriveOS
60 SS, + 3T Windows 7 
  hide details  
Reply
post #3 of 8
If writing code in notepad, save the file as "foo.java". (replace 'foo' with whatever you want.)

Open a command window and navigate to the folder containing the file. Then type "javac foo.java" and hit enter. This compiles the program into the foo.class file. Then, to run the program, type "java foo". This tells the JDK to run the .class file.

Alternatively, you can use an IDE such as netBeans that Oaff reccomended, or eclipse. Personally, I use eclipse for no other reason than its what we have/use at school. Eclipse offers many plugins, including some for GWT should you ever get into that.

An IDE offers many features that will help with coding, including debuging, syntax highlighting, code completion, etc. If you are serious about learning java, learn an IDE along side it after you try your first hello world app.

Hope this helps!
    
CPUMotherboardGraphicsGraphics
i7 2600k Asus P8P67 Pro 2x EVGA 580GTX 3GB 2x Saphire 7970 Vapor-x GHz edition (alternate) 
RAMHard DriveHard DriveCooling
16GB G.Skill 2133 CAS9 Hitachi 3tb Corsair M4 128 CM 212+ 
OSMonitorMonitorKeyboard
Arch Linux, OSX, Win7x64 Dell U3011  HP LP3065 Leopold Mechanical Blue 
PowerCaseMouseAudio
Seasonic X1250 Modular Corsair 750d Razer Deathadder V3.5? Bose companion 3 Series II 
Audio
Sennheiser HD-280 Pro 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
i7 2600k Asus P8P67 Pro 2x EVGA 580GTX 3GB 2x Saphire 7970 Vapor-x GHz edition (alternate) 
RAMHard DriveHard DriveCooling
16GB G.Skill 2133 CAS9 Hitachi 3tb Corsair M4 128 CM 212+ 
OSMonitorMonitorKeyboard
Arch Linux, OSX, Win7x64 Dell U3011  HP LP3065 Leopold Mechanical Blue 
PowerCaseMouseAudio
Seasonic X1250 Modular Corsair 750d Razer Deathadder V3.5? Bose companion 3 Series II 
Audio
Sennheiser HD-280 Pro 
  hide details  
Reply
post #4 of 8
Just to add to the above, you need to set a JAVA_HOME environment variable in Windows if you want to enable the use of the 'javac' and 'java' commands in the command prompt. Here's what it looks like in XP:



Doing so will allow you to code in Notepad and compile + run in the command prompt.
    
CPUMotherboardGraphicsGraphics
2600k @ 4.6Ghz Biostar TP67XE Powercolor 6870x2 Sapphire 6870 
RAMHard DriveHard DriveHard Drive
4 x 4GB Patriot Viper Xtreme @ 1600 CL8 Intel X-25M 80Gb Hitachi Deskstar 1Tb Seagate 1Tb 
CoolingCoolingMonitorPower
Cogage Arrow 2x Thermalright TY-140 Yamakasi 2703 2560x1440 Seasonic S12D 850w 
Case
Aerocool VS-9 Ghetto Mod 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
2600k @ 4.6Ghz Biostar TP67XE Powercolor 6870x2 Sapphire 6870 
RAMHard DriveHard DriveHard Drive
4 x 4GB Patriot Viper Xtreme @ 1600 CL8 Intel X-25M 80Gb Hitachi Deskstar 1Tb Seagate 1Tb 
CoolingCoolingMonitorPower
Cogage Arrow 2x Thermalright TY-140 Yamakasi 2703 2560x1440 Seasonic S12D 850w 
Case
Aerocool VS-9 Ghetto Mod 
  hide details  
Reply
post #5 of 8
Quote:
Originally Posted by Infinite-Dev View Post
If writing code in notepad, save the file as "foo.java". (replace 'foo' with whatever you want.)

Open a command window and navigate to the folder containing the file. Then type "javac foo.java" and hit enter. This compiles the program into the foo.class file. Then, to run the program, type "java foo". This tells the JDK to run the .class file.

Alternatively, you can use an IDE such as netBeans that Oaff reccomended, or eclipse. Personally, I use eclipse for no other reason than its what we have/use at school. Eclipse offers many plugins, including some for GWT should you ever get into that.

An IDE offers many features that will help with coding, including debuging, syntax highlighting, code completion, etc. If you are serious about learning java, learn an IDE along side it after you try your first hello world app.

Hope this helps!


One side note: if you plan on trying out android development you should go with eclipse. Netbeans didn't have decent android support the last time I checked.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
1100t Asus m4A78T-E HIS 5850 4G 
Hard DriveOS
60 SS, + 3T Windows 7 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
1100t Asus m4A78T-E HIS 5850 4G 
Hard DriveOS
60 SS, + 3T Windows 7 
  hide details  
Reply
post #6 of 8
Thread Starter 
Thanks a lot for the help. I had not paths for the jdr so command prompt wasn't finding the compiler. Appreciate the help, reps awarded, time to code!
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
post #7 of 8
Quote:
Originally Posted by Nailuj View Post
Thanks a lot for the help. I had not paths for the jdr so command prompt wasn't finding the compiler. Appreciate the help, reps awarded, time to code!
just curious but why are you using notepad instead of notepad++, netbeans, or eclipse?? All three are far better than notepad alone, two of which compile for you. Also, if you do know C++ and C# make sure to download the JDK for it. I got everything here: link
OverKill
(18 items)
 
  
CPUMotherboardGraphicsGraphics
AMD Phenom II X6 1055T Gigabyte 890FXA ATI FirePro V3800 ATI FirePro V3800 
RAMHard DriveHard DriveOptical Drive
16gb GSkill 10666 Seagate Western Digital  LG Blue Ray 
CoolingOSMonitorMonitor
stock air 7 Pro 64 bit (2)22" Acer x223w (2)23" Acer G235H 
KeyboardPowerCaseMouse
Microsoft Wireless Antec 900watt Antec 300 Wacom Tablet 
Audio
Logitech Speakers and sub 
  hide details  
Reply
OverKill
(18 items)
 
  
CPUMotherboardGraphicsGraphics
AMD Phenom II X6 1055T Gigabyte 890FXA ATI FirePro V3800 ATI FirePro V3800 
RAMHard DriveHard DriveOptical Drive
16gb GSkill 10666 Seagate Western Digital  LG Blue Ray 
CoolingOSMonitorMonitor
stock air 7 Pro 64 bit (2)22" Acer x223w (2)23" Acer G235H 
KeyboardPowerCaseMouse
Microsoft Wireless Antec 900watt Antec 300 Wacom Tablet 
Audio
Logitech Speakers and sub 
  hide details  
Reply
post #8 of 8
Thread Starter 
Quote:
Originally Posted by graphicsman View Post
just curious but why are you using notepad instead of notepad++, netbeans, or eclipse?? All three are far better than notepad alone, two of which compile for you. Also, if you do know C++ and C# make sure to download the JDK for it. I got everything here: link
Oh I was planning on using eclipse but im using notepad and command prompt simply to become familiar with how things work outside of an IDE. I've used Visual studio for a year now and find it pretty useful with C++ and notepad++ its pretty awesome (found it useful for matlab code cause the editor was acting up).

Thanks for the links
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
Old Puppy
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500K gigabyte z68A-D3H-B3 XFX HD6870 1GB 8GB G.Skill Ripjaws 
Hard DriveOSMonitorPower
120GB Kingston HyperX Win 7 ultimate x64 Benq G2222HDL XFX PRO650W Core Edition 
Case
NZXT Whisper 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Java-How do I actually use the JDK?