The Warring States of NPF

The Warring States of NPF (http://www.nuklearforums.com/index.php)
-   Computers & Technology (http://www.nuklearforums.com/forumdisplay.php?f=60)
-   -   Want to learn Java (http://www.nuklearforums.com/showthread.php?t=39718)

Pip Boy 03-07-2011 01:44 AM

Want to learn Java
 
Trying to learn some basic coding and someone suggested I start out with Java. Last time I tried to learn any kind of code, it was C, and went horribly, not because of the code itself but because of the compiler being a motherfucker to use and having tutorials that I swear to god looked like they were written for a different program completely.

That was about a year ago now, and I've decided to take another swing at this. Someone pointed me towards Eclipse to start learning to mess with JavaScript, and I'm running into the same problem again. Part of one of the earliest tutorials points me towards a part of their website that no longer exists tells me to import an archive that it won't let me import.

(To be more specific, the path to the file I was meant to download from their site is no longer the same path specified in the tutorial. I managed to find something that I think is it with a google search, but even when I downloaded it and attempted to import it to Eclipse, I encountered a problem when following its instructions. It simply says to select the archive to import from a specific menu and then hit "finish", but when I selected the archive the "finish" button was grayed/unuseable as if it were waiting for me to set God knows what other settings before I could move on.)

Getting kind of sick trying to wade through this bullshit, so I thought I'd just pop in and ask if anyone knows a good program to learn this with. Preferably one with tutorials that, when you follow them to the letter, actually tell you the correct thing to do in the current version of the program and not the one that they released 10 years ago before they made a bunch of arbitrary changes to the interface that make their instructions meaningless.

Doc ock rokc 03-07-2011 03:31 AM

Actually I suggest Trying PYTHON first as its VERY forgiving and Has a Huge Import library.

Stick with 2.7.1 as it has a much larger tut base.
I can even PM you some of my college class power-points on the subject.

synkr0nized 03-07-2011 05:29 AM

if (forum == "Computers & Technology") { return helpful_post; } else { lol();}
 
Javascript and Java are different beasts, though they do share a lot of syntax and style, for lack of a better word.

Eclipse is a nice SDK when it behaves. It is a rather "large" program, though, so it can seem overwhelming. I am not good help for Eclipse, as I tend to rush through installation and setup and haven't ever really gotten a knack for helping others do it. Still, when it's running, it can auto-complete a lot of things for you and keep track of all that junk that makes having an SDK great.

Interesting that you were having problems with C and a compiler. Do you recall what you were using? Microsoft's free Visual C++ was pretty straightforward, or so I thought, and in a Unix or Unix-like environment you just need to make sure you have gcc/g++ installed.


Generally, O'Reilly books are good for learning, or so is common opinion among many of my colleagues. However, you may not find them to your liking. Might I suggest that you head to a Barnes and Noble/Borders/whatever book store and flip through the Java/coding textbooks and references and see if they resonate with you? You may find one that has a tutorial that builds upon itself each chapter or that's written less for a computer scientist and programmer and more for a student or hobbyist.


I learned Java with a textbook in one hand and a browser at the ready to peruse the API and documentation online while I worked on projects -- kind of sink or swim, as this was not in a classroom setting but rather a work setting. I'm sure it helped that I already had my learning and experience in other languages behind me, as once you get that kind of thinking down it's mostly a matter of learning any differences in syntax and how to make use of libraries and common functions. But I wouldn't recommend that to someone starting from scratch.


What's your goal for learning? If it's long-term or "big" enough and you are still in school you might want to see if you can take advantage of intro programming courses. I can't speak for every school, of course, but that should at least get you on your way and might count for credits and electives if you need them anyway.

bluestarultor 03-07-2011 10:48 AM

I learned Java in a class and did it all manually until about the last quarter or so when Eclipse was introduced.

First off, if you're using Eclipse for Javascript, you're doing it wrong. Javascript is not Java and is not a full programming language. Java is. Using Eclipse for Java should work just fine without needing any additional packages.

Basically, what I'm saying is you need to figure out what you're actually trying to do. Eclipse should work just fine for Java. For Javascipt, that's something you'd want to be integrating into HTML.

Pip Boy 03-07-2011 12:01 PM

My bad. I was assuming Javascript and Java were the same thing. Calling it Javascript was a mistake on my part, and what I was working with was just plain old Java. Besides, at this point none of the problems I've encountered actually relate to the code, but the fact that the tutorials that come built into the program to tell you how to do things don't actually correctly tell you how to do things on that program, as following them to the letter takes you to a lot of dead ends and things that you kind of have to guess and hope you did correctly because they do fuck all to help.

Does anyone know of a good place to find some tutorials to teach the basics of Java? I've pretty much given up on using the ones they have built in.

@ Synk: The problems I was having with C I actually posted a thread about here maybe a year back or so. I can't remember exactly what compiler it was, simply that it was a free one I'd gotten when someone told me about it. The problem I'd been having was that programs weren't compiling correctly for some reason. I'd literally copied and pasted the code it said I should use for a "Hello World" and it failed to compile that because of some nonsense. The fact that I keep running into these problems right off the bad is infuriating. I feel like if I learned enough about C or Java or whatever to know what I'm doing enough to identify my mistakes, it wouldn't be so bad, but stupid shit always comes up right when Im just starting out and its like gibberish to me.

bluestarultor 03-07-2011 01:41 PM

Well, to put it like this, I started small in my class. Start with basic drawing and see if you can make a face. Just a simple smiley face. That was my first assignment - to make one round happy face and one square sad face.

Of course, me being me, I blew the assignment out of the water:

PHP Code:

/******************************
 * Java Programming 152-116
 * Programmer: Joseph Bauer
 * Instructor: John Heckendorf
 * Lab Assignment: Faces.java
 ******************************/

import java.awt.*;
import javax.swing.*;

/*
<Applet code="Faces" height="400" width="400">
</Applet>
*/

public class Faces extends JApplet
{
    public 
void paint(Graphics oGraphics)
    {
        
super.paint(oGraphics);

        
SmileFace(oGraphics);
        
FrownFace(oGraphics);
    }

    private 
void SmileFace(Graphics gObj)
    {
        
//Draws a round, smiling face.

        //Draw base of circle.
        
gObj.setColor(Color.ORANGE);
        
gObj.fillOval(63100100100);

        
//Draw highlight.
        
gObj.setColor(Color.YELLOW);
        
gObj.fillOval(651009595);

        
//Draw eyebrows.
        
gObj.setColor(Color.ORANGE);
        
gObj.fillArc(1251252010165, -165);
        
gObj.fillArc(801252010165, -165);

        
//Draw nose shadow.
        
gObj.fillOval(1001302727);

        
//Draw nose.
        
gObj.setColor(Color.YELLOW);
        
gObj.fillOval(1001302720);

        
//Draw mouth.
        
gObj.setColor(Color.WHITE);
        
gObj.fillArc(751357550176188);

        
//Draw teeth.
        
gObj.setColor(Color.PINK);
        
gObj.drawArc(751477525176188);
        
gObj.drawLine(112168112177);
        
gObj.drawRect(11117024);
        
gObj.drawLine(9416894174);
        
gObj.drawRect(9317022);
        
gObj.drawLine(130168130174);
        
gObj.drawRect(12917022);
        
gObj.drawLine(8216482169);
        
gObj.drawLine(8116681167);
        
gObj.drawLine(143164143169);
        
gObj.drawLine(144166144167);

        
//Draw outline of mouth.
        
gObj.setColor(Color.ORANGE);
        
gObj.drawArc(751357550176188);
        
gObj.drawArc(75155755176188);

        
//Draw eyes.
        
gObj.setColor(Color.BLACK);
        
gObj.fillOval(851301010);
        
gObj.fillOval(1301301010);

        
//Draw wateriness.
        
gObj.setColor(Color.WHITE);
        
gObj.fillOval(8513077);
        
gObj.fillOval(13013077);
        
gObj.fillOval(9013633);
        
gObj.fillOval(13513633);


        
//Write caption.
        
gObj.setColor(Color.RED);
        
gObj.drawString("A happy Java programmer"40235);
    }

    private 
void FrownFace(Graphics gObj)
    {
        
//Draws a square, frowning face.


        //Make all of the arrays needed for the polygons.
        
int[] xBottom = {250350325275};
        
int[] yBottom = {195195203203};

        
int[] xNose = {300307293};
        
int[] yNose = {150157157};

        
int[] xBridge = {300300293};
        
int[] yBridge = {125150157};

        
int[] xShadow = {300300307};
        
int[] yShadow = {127150157};

        
int[] xLip = {296304306294};
        
int[] yLip = {178178182182};

        
//Draws basic square.
        
gObj.setColor(Color.CYAN);
        
gObj.fillRect(25010010095);

        
//Draw shadow on nose bridge.
        
gObj.setColor(Color.GREEN);
        
gObj.fillPolygon(xShadowyShadow3);

        
//Draw progressive shading on the eyebrows.
        
gObj.drawLine(264129279119);
        
gObj.drawLine(316119331129);

        
//Draw the shadow of the lower lip.
        
gObj.fillPolygon(xLipyLip4);

        
//Draws underside of box.
        
gObj.setColor(Color.BLUE);
        
gObj.fillPolygon(xBottomyBottom4);

        
//Draw the underside of the nose.
        
gObj.fillPolygon(xNoseyNose3);

        
//Draw eyebrows' dark shadow.
        
gObj.drawLine(265130280120);
        
gObj.drawLine(315120330130);

        
gObj.drawLine(265131280121);
        
gObj.drawLine(315121330131);

        
gObj.drawLine(331131333128);

        
//Draw the mouth.
        
gObj.drawLine(293175307175);
        
gObj.drawLine(291176292176);
        
gObj.drawLine(308176309176);

        
//Draw the lower lip.
        
gObj.drawLine(297178303178);

        
//Draw eyes.
        
gObj.setColor(Color.BLACK);
        
gObj.fillOval(2751301010);
        
gObj.fillOval(3151301010);

        
//Draw wateriness.
        
gObj.setColor(Color.WHITE);
        
gObj.fillOval(27513077);
        
gObj.fillOval(31513077);
        
gObj.fillOval(28013633);
        
gObj.fillOval(32013633);

        
//Draw nose bridge.
        
gObj.fillPolygon(xBridgeyBridge3);

        
//Draw reflection on the eyebrows.
        
gObj.drawLine(262127277117);
        
gObj.drawLine(318117333127);

        
gObj.drawLine(262126277116);
        
gObj.drawLine(318116333126);

        
//Draw the reflection on the sides of the brows.
        
gObj.drawLine(262126264130);
        
gObj.drawLine(315120318116);
        
gObj.drawLine(278117280120);

        
//Draw tiny teeth.
        
gObj.drawLine(295175305175);

        
//Draw the tear.
        
gObj.drawOval(31814866);
        
gObj.fillOval(31814844);

        
//Fix the tear.
        
gObj.setColor(Color.CYAN);
        
gObj.fillOval(32015033);


        
//Draw text.
        
gObj.setColor(Color.BLUE);
        
gObj.drawString("A sad non-Java programmer"225235);
    }



That's just me being obsessive, though. The teacher actually put it up in front of the class and said it was "one of the best" he'd ever seen. He then started asking me how I'd done some of it, so methinks "one of the" didn't quite cover it.

Seriously, though, pick it apart. If you'd like more code to look at, I saved everything from that class and can zip up projects of any complexity you want, up to and including a Pepsi machine.

Red Fighter 1073 03-07-2011 02:34 PM

Hahahaha Blues, GUI was like the LAST thing I did in my Java I intro class and you start doing it right off the bat. But first off, I would definitely suggest getting some kind of book from a public library or something like that because online tutorials can be confusing unless you specifically know what exact topic you're trying to find out and learn.

Also Eclipse is a bit of a weird compiler to get used to and honestly, I've only started using it in my Java II class with one of worst teachers I have ever had (Seriously, I'm sick of having teachers that give hard-as-fuck assignments and can't teach). It's kind of what I understand to be the one of the better heavy-duty compilers out there, but like I said, it is a bit hard to get used to. I used Dr Java in my intro class last semester and it was really easy to pick up and learn.

EDIT: Damnit Blues, I just tested that code and even my last GUI project wasn't that detailed.

bluestarultor 03-07-2011 02:48 PM

Quote:

Originally Posted by Red Fighter 1073 (Post 1113206)
Hahahaha Blues, GUI was like the LAST thing I did in my Java I intro class and you start doing it right off the bat. But first off, I would definitely suggest getting some kind of book from a public library or something like that because online tutorials can be confusing unless you specifically know what exact topic you're trying to find out and learn.

Also Eclipse is a bit of a weird compiler to get used to and honestly, I've only started using it in my Java II class with one of worst teachers I have ever had (Seriously, I'm sick of having teachers that give hard-as-fuck assignments and can't teach). It's kind of what I understand to be the one of the better heavy-duty compilers out there, but like I said, it is a bit hard to get used to. I used Dr Java in my intro class last semester and it was really easy to pick up and learn.

EDIT: Damnit Blues, I just tested that code and even my last GUI project wasn't that detailed.

You should see my Pepsi machine. :dance:



EDIT: On Eclipse, it's really a lot like Visual Studio in many ways. I didn't have a hard time adjusting myself, but I'll admit I had a lot of Visual Studio experience behind me. Eclipse is a big one in the industry from what I hear, though, so if you plan to do things professionally, it's a good thing to learn how to use.

I have to jump into the "get a book" boat, though. Online tutorials are just never quite as helpful as textbooks. You'll want something that gives you projects to put things into practice bit by bit. That really helps.

Pip Boy 03-07-2011 03:12 PM

Quote:

Originally Posted by bluestarultor (Post 1113199)
Well, to put it like this, I started small in my class. Start with basic drawing and see if you can make a face. Just a simple smiley face. That was my first assignment - to make one round happy face and one square sad face.

Of course, me being me, I blew the assignment out of the water:

PHP Code:

/******************************
 * Java Programming 152-116
 * Programmer: Joseph Bauer
 * Instructor: John Heckendorf
 * Lab Assignment: Faces.java
 ******************************/

import java.awt.*;
import javax.swing.*;

/*
<Applet code="Faces" height="400" width="400">
</Applet>
*/

public class Faces extends JApplet
{
    public 
void paint(Graphics oGraphics)
    {
        
super.paint(oGraphics);

        
SmileFace(oGraphics);
        
FrownFace(oGraphics);
    }

    private 
void SmileFace(Graphics gObj)
    {
        
//Draws a round, smiling face.

        //Draw base of circle.
        
gObj.setColor(Color.ORANGE);
        
gObj.fillOval(63100100100);

        
//Draw highlight.
        
gObj.setColor(Color.YELLOW);
        
gObj.fillOval(651009595);

        
//Draw eyebrows.
        
gObj.setColor(Color.ORANGE);
        
gObj.fillArc(1251252010165, -165);
        
gObj.fillArc(801252010165, -165);

        
//Draw nose shadow.
        
gObj.fillOval(1001302727);

        
//Draw nose.
        
gObj.setColor(Color.YELLOW);
        
gObj.fillOval(1001302720);

        
//Draw mouth.
        
gObj.setColor(Color.WHITE);
        
gObj.fillArc(751357550176188);

        
//Draw teeth.
        
gObj.setColor(Color.PINK);
        
gObj.drawArc(751477525176188);
        
gObj.drawLine(112168112177);
        
gObj.drawRect(11117024);
        
gObj.drawLine(9416894174);
        
gObj.drawRect(9317022);
        
gObj.drawLine(130168130174);
        
gObj.drawRect(12917022);
        
gObj.drawLine(8216482169);
        
gObj.drawLine(8116681167);
        
gObj.drawLine(143164143169);
        
gObj.drawLine(144166144167);

        
//Draw outline of mouth.
        
gObj.setColor(Color.ORANGE);
        
gObj.drawArc(751357550176188);
        
gObj.drawArc(75155755176188);

        
//Draw eyes.
        
gObj.setColor(Color.BLACK);
        
gObj.fillOval(851301010);
        
gObj.fillOval(1301301010);

        
//Draw wateriness.
        
gObj.setColor(Color.WHITE);
        
gObj.fillOval(8513077);
        
gObj.fillOval(13013077);
        
gObj.fillOval(9013633);
        
gObj.fillOval(13513633);


        
//Write caption.
        
gObj.setColor(Color.RED);
        
gObj.drawString("A happy Java programmer"40235);
    }

    private 
void FrownFace(Graphics gObj)
    {
        
//Draws a square, frowning face.


        //Make all of the arrays needed for the polygons.
        
int[] xBottom = {250350325275};
        
int[] yBottom = {195195203203};

        
int[] xNose = {300307293};
        
int[] yNose = {150157157};

        
int[] xBridge = {300300293};
        
int[] yBridge = {125150157};

        
int[] xShadow = {300300307};
        
int[] yShadow = {127150157};

        
int[] xLip = {296304306294};
        
int[] yLip = {178178182182};

        
//Draws basic square.
        
gObj.setColor(Color.CYAN);
        
gObj.fillRect(25010010095);

        
//Draw shadow on nose bridge.
        
gObj.setColor(Color.GREEN);
        
gObj.fillPolygon(xShadowyShadow3);

        
//Draw progressive shading on the eyebrows.
        
gObj.drawLine(264129279119);
        
gObj.drawLine(316119331129);

        
//Draw the shadow of the lower lip.
        
gObj.fillPolygon(xLipyLip4);

        
//Draws underside of box.
        
gObj.setColor(Color.BLUE);
        
gObj.fillPolygon(xBottomyBottom4);

        
//Draw the underside of the nose.
        
gObj.fillPolygon(xNoseyNose3);

        
//Draw eyebrows' dark shadow.
        
gObj.drawLine(265130280120);
        
gObj.drawLine(315120330130);

        
gObj.drawLine(265131280121);
        
gObj.drawLine(315121330131);

        
gObj.drawLine(331131333128);

        
//Draw the mouth.
        
gObj.drawLine(293175307175);
        
gObj.drawLine(291176292176);
        
gObj.drawLine(308176309176);

        
//Draw the lower lip.
        
gObj.drawLine(297178303178);

        
//Draw eyes.
        
gObj.setColor(Color.BLACK);
        
gObj.fillOval(2751301010);
        
gObj.fillOval(3151301010);

        
//Draw wateriness.
        
gObj.setColor(Color.WHITE);
        
gObj.fillOval(27513077);
        
gObj.fillOval(31513077);
        
gObj.fillOval(28013633);
        
gObj.fillOval(32013633);

        
//Draw nose bridge.
        
gObj.fillPolygon(xBridgeyBridge3);

        
//Draw reflection on the eyebrows.
        
gObj.drawLine(262127277117);
        
gObj.drawLine(318117333127);

        
gObj.drawLine(262126277116);
        
gObj.drawLine(318116333126);

        
//Draw the reflection on the sides of the brows.
        
gObj.drawLine(262126264130);
        
gObj.drawLine(315120318116);
        
gObj.drawLine(278117280120);

        
//Draw tiny teeth.
        
gObj.drawLine(295175305175);

        
//Draw the tear.
        
gObj.drawOval(31814866);
        
gObj.fillOval(31814844);

        
//Fix the tear.
        
gObj.setColor(Color.CYAN);
        
gObj.fillOval(32015033);


        
//Draw text.
        
gObj.setColor(Color.BLUE);
        
gObj.drawString("A sad non-Java programmer"225235);
    }



That's just me being obsessive, though. The teacher actually put it up in front of the class and said it was "one of the best" he'd ever seen. He then started asking me how I'd done some of it, so methinks "one of the" didn't quite cover it.

Seriously, though, pick it apart. If you'd like more code to look at, I saved everything from that class and can zip up projects of any complexity you want, up to and including a Pepsi machine.

Presumably there was some instruction about syntax and how to make basic lines and shapes before they asked you to make a face. That instruction is what I'm looking for. I don't know the first thing about Java syntax or commands.

bluestarultor 03-07-2011 03:26 PM

Quote:

Originally Posted by Pip Boy (Post 1113216)
Presumably there was some instruction about syntax and how to make basic lines and shapes before they asked you to make a face. That instruction is what I'm looking for. I don't know the first thing about Java syntax or commands.

Java uses a C-like syntax, which is why the PHP highlighting worked on it. If you did a bit in C, Java should be easy to pick up.

What you can do, if you're using Eclipse, is hit the space bar to kick up a suggestion menu. Just type in a command you know, or most of it, hit space, and browse through all the commands. IIRC, clicking on them or maybe hovering kicks up a description of what things do.

But, again, easiest way is probably to get a book.


All times are GMT -5. The time now is 01:28 AM.

Powered by: vBulletin Version 3.8.5
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.