![]() |
|
|
#1 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
Help a beginner with Java
<Original question answered>
Edit: I'll post more questions as I'm learning. Last edited by Tatty_One; Jul 5, 2011 at 08:16 PM. Reason: OP request |
|
|
|
|
|
#2 |
![]() Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.51/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts
|
If you already have it working for classes why doesn't it work for javac? Maybe you just need to use something like "javac .\myfile.java"?
All you should need to do is add the Java directory to the "path" system variable.
__________________
|
|
|
|
|
|
#3 |
|
Linux Advocate
Join Date: Nov 2006
Posts: 10,284 (4.27/day)
Thanks: 1,219
Thanked 2,789 Times in 1,801 Posts
|
set the path for it i believe.
|
|
|
|
|
|
#4 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
How do you set the path for it? I've been reading around and am completely confused.
|
|
|
|
|
|
#5 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
Another question.
Spoiler
|
|
|
|
|
|
#6 | |
![]() Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.51/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts
|
Quote:
![]() Then select Environment Variables and you'll see this window. ![]() Then click "Path" in the lower box and hit "Edit" and you'll get here: ![]() Then just add a semicolon and the path to your Java directory (with javac). I'm pretty sure that's correct, though my terminology is a bit rusty.
__________________
Last edited by streetfighter 2; Jul 5, 2011 at 07:13 PM. |
|
|
|
|
| The Following User Says Thank You to streetfighter 2 For This Useful Post: |
|
|
#7 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
I ignored path and thought I had to add SOURCEPATH
![]() Edit: I've already done that what I meant was how do I set it (cmd) to know where my .java files are, not javac. Last edited by razaron; Jul 7, 2011 at 07:44 PM. |
|
|
|
|
|
#8 | |
![]() Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.51/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts
|
Quote:
You have to type in the directory of your .java files at one time or another. The idea is usually to cd into the directory with your .java files and then all you need to do is type "javac myfile.java". You could also make a batch file which would simplify the process even further.
__________________
|
|
|
|
|
|
|
#9 |
|
Linux Advocate
Join Date: Nov 2006
Posts: 10,284 (4.27/day)
Thanks: 1,219
Thanked 2,789 Times in 1,801 Posts
|
first off, not to be a dick, but you gotta correct your grammar. i had to read your question 3 times before i figured out what you were asking. better grammar means more people willing to help.
a .java file is the source code. you run javac on the .java file to compile it into a class file which you then execute running the java <your java class file>. so you have to either be in the directory of your compiled java program or include the entire working directory. |
|
|
|
|
|
#10 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
I just changed the default start directory for a shortcut of cmd. That solves that problem.
I couldn't think of a better way to word it (otherwise I would've just googled it...) |
|
|
|
|
|
#11 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
I popped my programing cherry.
Spoiler
I'm going to practice with maths for now then do that archery thing Kreij mentioned in another thread. PS. Is it bad to have to regularly look up syntax? |
|
|
|
|
|
#12 |
![]() Join Date: Nov 2006
Location: At your local vending machine
Posts: 1,914 (0.80/day)
Thanks: 121
Thanked 419 Times in 368 Posts
|
Not at all for a beginner!
![]() I still have to look up syntax for some things. The more you do it, the easier it will become and the less you will have to reference
__________________
My FS/FT Thread
HEATWARE Xfire Steam ID Certs: MCTS, MCITP, HP APS Server: AMD Opteron 170 @2.95GHz | 4GB DDR 3-3-2-7 | 1x Samsung SPT 500GB, 2x WD Black 2TB, 2x 1.5TB Western Digital MyBook |
|
|
|
| The Following User Says Thank You to A Cheese Danish For This Useful Post: |
|
|
#13 |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
No raz, with 1000s of APIs and a jillion methods that are available in some of the modern programming languages, and the fact that with language revisions they will add/obsolete calls, you will be using references constantly.
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
|
|
|
|
| The Following User Says Thank You to Kreij For This Useful Post: |
|
|
#14 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
I was looking for java keyword definitions and found them on Wikipedia. The definition of "void" has me confused.
Wikipedia defines void as, "The void keyword is used to declare that a method does not return any value.", if that's true how did the code I posted earlier return a value? ![]() EDIT: Also, can any of you folks remember how long it took you to start using correct case letters (upper/lowercase) in code? That seems to be the commonest error I make. Last edited by razaron; Jul 7, 2011 at 10:33 AM. |
|
|
|
|
|
#15 |
![]() Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.41/day)
Thanks: 567
Thanked 606 Times in 487 Posts
|
That's because it didn't return anything, unlike this (poor) example:
Code:
public int getTheNumberTen() {
return 10;
}
|
|
|
|
|
|
#16 | ||
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
Then would I be correct in assuming returning a value means "returning a value to the code"?
Another question: The following code makes cmd say "Your target is x" where x is a value. Quote:
Quote:
Last edited by razaron; Jul 7, 2011 at 12:44 PM. |
||
|
|
|
|
|
#17 |
![]() Join Date: Aug 2007
Location: Geneva, FL, USA
Posts: 3,010 (1.41/day)
Thanks: 567
Thanked 606 Times in 487 Posts
|
Seems like you're missing a "+" after the x_target variable. You need it to concatenate " meters away" with the beginning portion.
That's one way to describe it. It's going to return the result so you may do with it as you will. Ex: Lets say you have a function that returns a value describing how close a user got to the the target based on the angle, meters away, and the bow pull. It's something that you want to print out, but also save in an array so that the user can see their last ten moves or something like that. Code:
proximity = getProximity(angle, meters, power) Note: Much more familiar with PHP, sorry if my Java syntax is off. |
|
|
|
| The Following User Says Thank You to Jizzler For This Useful Post: |
|
|
#18 | ||
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
Is it better to have several small formulae,
Quote:
or one big formula, Quote:
|
||
|
|
|
|
|
#19 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
So far I have this for the archery game,
Spoiler
How do I make it return to the bit just after it's worked out "x_target" if "d_target" > 1? Other than that it works, yay. EDIT: I can advertise this game as using real Newtonian physics, lol. Last edited by razaron; Jul 7, 2011 at 03:18 PM. |
|
|
|
|
|
#20 |
![]() Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.51/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts
|
Is this what you want?
Spoiler
__________________
|
|
|
|
| The Following User Says Thank You to streetfighter 2 For This Useful Post: |
|
|
#21 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
Couldn't get what you wrote to work. However that helped me learn the do-while thing, so thank you.
![]() Here's my awesome game: Spoiler
|
|
|
|
| The Following User Says Thank You to razaron For This Useful Post: |
|
|
#22 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
What would be a logical step up from the archery game? Preferably something that doesn't require much imagination (so no text adventure).
|
|
|
|
|
|
#23 |
![]() Join Date: Aug 2009
Location: Los Angeles/Orange County CA
Posts: 1,144 (0.82/day)
Thanks: 2,028
Thanked 383 Times in 308 Posts
|
My advice is to learn Perl or Python or even C.
I hate Java. It's buggy as hell. |
|
|
|
|
|
#24 | |
![]() Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.51/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts
|
Quote:
I'd create a simple window with a couple edit controls (text boxes) for inputting theta/P and a button to start the simulation. Then I'd plot the arrows path and show the origin and target. It sounds complicated but it's actually very easy.
__________________
|
|
|
|
|
| The Following User Says Thank You to streetfighter 2 For This Useful Post: |
|
|
#25 |
![]() Join Date: Apr 2008
Location: london
Posts: 612 (0.33/day)
Thanks: 171
Thanked 187 Times in 142 Posts
|
What am I doing wrong with this piece of code?
Spoiler
I'm trying to make a 25 places big vector with each place containing an integer with the same value as the place itself (hence the (i, i)). Then it should display the 5th int in the vector. The errors: Spoiler
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Very noobi question in Java | Flash | Programming & Webmastering | 7 | Apr 20, 2011 06:31 PM |
| C# question (java related) | spy2520 | Programming & Webmastering | 33 | Feb 28, 2010 12:32 PM |
| My First Programming Question (Java) | spy2520 | Programming & Webmastering | 13 | Oct 29, 2009 03:17 AM |
| Java partially filled arrays question | wolf2009 | Programming & Webmastering | 1 | Apr 14, 2009 01:09 AM |
| Java Question | dcf-joe | Programming & Webmastering | 1 | Dec 24, 2008 01:12 PM |