1.

Solve : Java help.?

Answer»

I have a friend who learn Java in school and he asked me some stuff about it.
Normally I could answer them without knowing anything about java.
Just from my other programming knowledge.
But now it gets to complicated. And I do want to help him.
And I'm quiet interested in Java.
Sow my question is:
what do I need to be able to wright and test the self written porgs?
Is there any good tortural?

Thanks in advance

Jonas You need the Java Development Kit (JDK). Get the most recent version off ..

http://java.sun.com/javase/downloads/index.jsp

Get a java IDE, although not necessary, I recommend JCreator ..

http://jcreator.com/

First download the JDK, then download JCreator and open it.
After you open it, create a project.
Copy the program that you want into Jcreator, compile them, and then run it.

If you do not know any java, then read the TUTORIALS on ..

http://java.sun.com/docs/books/tutorial/

Ask me if you have any problems or need help with anything.
Thank you JavaMaster I will install that program and read the tutorials.
But I'm sure I will have some questions.
And it is nice to hear you want help me.

Jonas He told me that I already had it and asked me if I wanted to reïnstall it.
So I did that but I'm unable to find the program.
Where should it be located?
I checked all programs, C:\program files\java But I couldn't find any link to JDK.

Thanks in advance
Jonas hello jonas
well if u have already INSTALLED java, then go in ur C DRIVE, u must be havin a FOLDER named j2sdk1.4 or j2sdk1.5 . for convenience rename it if u like, as this name is too long. suppose yo rename it to jdk1.4
then to write a java program, go on the command prompt and type cd\
now type:
cd jdk1.4 {to enter it}
cd bin
edit abc.java {to write a java file named abc}
save it and exit
now on command prompt type:
javac abc.java {to compile ur program}
java abc {to run ur program}

and if u want to check the note pad file of ur program then go in C drive -> jdk1.4 ->
bin, and u will find it.
i hope it helped.
Thks that was what I was looking for.
But I do have a problem:
when I try to compile it it says 9 errors while it works perfectly at my friends comp.
But he has a special program. He uses trough a VPN connection with his school.
It gives me errors that doesn't make any sense

Is there any thing wrong with the prog he wrote? (I don't think so but still)

Jonas

Here is the program:
Code: [Select]public void Ster1 (int n)
{
int x;
int index;
for (x = 1; x <= n; x++)
{
for (index = 1; index <= x ; index++)
{
System.out.print ("*");
}
System.out.print (" ");
}
}
hi jonas,
alwz remember that any function in java has to be declared within a class .
also there has to be a main function in your program. it is declared as follows:
class abc
{
public static void main(String str[])
{
---------------
}
}
public key word is used to make it accessible to all.
static is used so that, we can USE it without creating its object.
void - its return type.
now, if you wish to write your program, there are three ways:
1> write the code in main function itself.
2> write the code in the same class. but dont forget to declare the new function also as static, bcoz a static function can call only a static function in the same class.
3> write the code in another class and make the object of that class in main function.

here is the code for the last option:


class star
{
public static void main(String a[])
{
int n=Integer.parseInt(a[0]);
star1 a1=new star1();
a1.ster1(n);
}
}
class star1
{
void ster1(int n)
{
int x;
int index;
for(x=1;x<=n;x++)
{
for(index=1;index<=x;index++)
{
System.out.print("*");
}
System.out.print(" ");
}
}
}

i hope it helped .



Discussion

No Comment Found