Java Pls Help!!!

Get help on programming - C++, Java, Delphi, etc.
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Java Pls Help!!!

Post by SBSP »

Hi I dont know anything about java.

But i would like to learn.

I downloaded sun_java_wireless_toolkit-2_5-beta2-windows toolkit.
Basically a cellphone emulator.

But what do i use to create code, i'm bussy downloading J studio as swell
What else do i need?

And if some 1 has basic Java skills how do I make a hello world application

Lets say with a black background and show text "Hello World" on my cellphone (In white text)

All i know is the end result is supposed to be a .JAR and .JAD file , I also noticed the Jar file is a Zip file and can be expanded using RAR

Pls help

Edit:
****************************************
Ok this is what ive done.
I copied the following into notepad

class HelloWorld {
public static void main(String[] args){
System.out.println("Hello World!");
}
}
Then saved it as c:\JavaLearn\Helotest.java
then went to the prompt and changed to C:\Program Files\Java\jdk1.5.0_06\bin

typed javac c:\JavaLearn\Helotest.java
it took a couple of sec and it created a Helotest.class file i then ran
java c:\JavaLearn\Helotest.class and it gives me some exception error.

Atleast now i now you compile a .java file to a class file. where does the .Jad and .Jar file come in to play, also what is wrong with my Hellotest.java code?
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

1) you can write code using notepad - J studio is an excellent IDE, but may confuse some issues for you
2) once the code has been compiled, (to bytecode), you would ordinarily pack it into a .jar file, using the jar's manifest to declare the main class, thereby permitting the JRE, (java runtime environment), to 'auto-execute' it.

admittedly, i've never fiddled with the mobile side of java, so my knowledge is sketchy - i'm guessing the the wireless toolkit will provide you the necessary tools as far as the io specifics and packaging is concerned...

Code: Select all

public class HelloWorld{
 public static void main(String[] args){
  javax.swing.JFrame frm = new javax.swing.JFrame("My First Application");
  frm.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
  frm.getContentPane().add(new javax.swing.JLabel("Hello world!"), java.awt.BorderLayout.CENTER);
  frm.pack();
  frm.setLocationRelativeTo(null);
  frm.setVisible(true);
 }
}
as to your error... the filename HAS to be the same as the class name... thus, changing the file to HelloWorld.java and re-compiling should resolve the error... if not , post the exception here...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

Ok I copied the whole command.
C:\Program Files\Java\jdk1.5.0_06\bin>type HelloWorld.java
public class HelloWorld{
public static void main(String[] args){
javax.swing.JFrame frm = new javax.swing.JFrame("My First Application");
frm.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
frm.getContentPane().add(new javax.swing.JLabel("Hello world!"), java.awt.Bord
erLayout.CENTER);
frm.pack();
frm.setLocationRelativeTo(null);
frm.setVisible(true);
}
}
C:\Program Files\Java\jdk1.5.0_06\bin>
C:\Program Files\Java\jdk1.5.0_06\bin>
C:\Program Files\Java\jdk1.5.0_06\bin>
C:\Program Files\Java\jdk1.5.0_06\bin>javac HelloWorld.java

C:\Program Files\Java\jdk1.5.0_06\bin>java HelloWorld.class
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class

C:\Program Files\Java\jdk1.5.0_06\bin>
Maybe i have a config problem
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

dont specify ".class"... the interpreter presumes you are attempting to launch a pre-packed classs within an archive..

Code: Select all

java HelloWorld
should be sufficient...

also, after some browsing, i suspect that CLDC/MIDP does not support swing... will revert after a little investigation :wink:
Most people would sooner die than think; in fact, they do so - Bertrand Russel
TechnoMage
Registered User
Posts: 1
Joined: 13 Dec 2006, 02:00
Location: Where?

Post by TechnoMage »

I sugest you start off with pc apps. You will need a text edditor or IDE to generate code and and the java compiler. SciTE is a good text editor for small apps - like "hallo world".

Java compiler:
ftp://ftp.cs.up.ac.za/CD1/Programming/Java/Java_SDK/
Scite
ftp://ftp.cs.up.ac.za/CD1/Programming/Scite/Windows/

Search the net for a few tutorials...
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

<issues greets to TechnoMage>

welcome! :wink:

as for IDE, my first choice remains Eclipse... provides all the functionality found in Netbeans/JStudio, without the overhead...
<edit>
i would still advise that SBSP use a text editor to start off with. it's still the best way to get to know the language... the IDE, while great, tends to hide the crucial workings from the user, which results in confusion later...
</edit>
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

rustypup wrote:dont specify ".class"... the interpreter presumes you are attempting to launch a pre-packed classs within an archive..

Code: Select all

java HelloWorld
should be sufficient...

also, after some browsing, i suspect that CLDC/MIDP does not support swing... will revert after a little investigation :wink:
Dude you rock!!!!

It works.

I also started a new project with jstudio
/*
* Main.java
*
* Created on December 14, 2006, 12:30 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Billy.Bob :)
*/
public class Main {

/** Creates a new instance of Main */
public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Hello World!");
}

}
it works as well and is also creted me a Jar file and as far as JAD files goes
is seems like its only relivant to Mobile development.


I downloaded a JAD creator but it find some errors in the Jar file it cant extract it so mabe its a crappy jad creator.

Wil chck for some official applications hopefully java has one.
Last edited by SBSP on 14 Dec 2006, 12:45, edited 1 time in total.
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

oh crap now every body knows my name!
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Post by Ron2K »

SBSP wrote:oh crap now every body knows my name!
Congrats, you've joined an exclusive club consisting of me, DAE_JA_VOO and Cameron. (And maybe a few others.)
Kia kaha, Kia māia, Kia manawanui.
LinkX
Registered User
Posts: 7333
Joined: 18 Jul 2005, 02:00
Location: Somewhere unknown... being ninja

Post by LinkX »

Ron2K wrote:
SBSP wrote:oh crap now every body knows my name!
Congrats, you've joined an exclusive club consisting of me, DAE_JA_VOO and Cameron. (And maybe a few others.)
isnt master-k, wikid and kickass also part of it
__________Image__________
Image---I'm out of my mind right now, but feel free to leave a message...---Image
PhReaK_K
Registered User
Posts: 884
Joined: 13 Dec 2006, 02:00
Location: behind you, fool !!
Contact:

Post by PhReaK_K »

If you want to make Mobile apps. Try using Netbeans and also download their Mobile aplication development tool. This will give you a nice step by step graphical representation of what you want to do. It is really easy and if you do not know much about JAVA it is still easy to use...

Go to www.sun.com and to the download section, Then just do a search for Netbeans. It is free. :wink:
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

ok... MIDP 2.0 API...

as i guessed, the ui components are all lightweight.. the link will take you the an online version of the API, but i suspect they will have a downloadable one somewhere as well..

the API is your bible in any such endeavor... have a gander to get a feel for its layout ... as well as some idea of what you can accomplish using j2me... i see the new API includes an openGL wrapper :D
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

rustypup wrote:ok... MIDP 2.0 API...

as i guessed, the ui components are all lightweight.. the link will take you the an online version of the API, but i suspect they will have a downloadable one somewhere as well..

the API is your bible in any such endeavor... have a gander to get a feel for its layout ... as well as some idea of what you can accomplish using j2me... i see the new API includes an openGL wrapper :D
OMG! 8O

I created my Jar file and used JAD maker to create a JAD file for it but
JAVWTK the emulator wont open it i get a error 13 whet ever in the hell that means.

Mabe the whole thing needs to be compiled with some diff ver of Java
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

have you installed the latest JDK, (6.0), as well as J2ME?...

what project type did you specify when creating it?.

JStudio allows you to specify which compiler to use with each project... right-click the project name in the tree and browse its poperties for the compiler... what compiler is selected?
Most people would sooner die than think; in fact, they do so - Bertrand Russel
PhReaK_K
Registered User
Posts: 884
Joined: 13 Dec 2006, 02:00
Location: behind you, fool !!
Contact:

Post by PhReaK_K »

Just install the Netbeans thing. It has got all the neccesary SDK for J2ME and J2SE that you will need. It also got a few tutorials if you really need it. Save time and effort.
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

rustypup wrote:have you installed the latest JDK, (6.0), as well as J2ME?...

what project type did you specify when creating it?.

JStudio allows you to specify which compiler to use with each project... right-click the project name in the tree and browse its poperties for the compiler... what compiler is selected?
I chose to create a Java Application under general.

Thanks for all the help I also found a link for some more help.

Very good btw
http://today.java.net/pub/a/today/2005/ ... tml?page=2
tHe_EnErGiZeR
Registered User
Posts: 16
Joined: 16 Oct 2006, 02:00

Post by tHe_EnErGiZeR »

I have recently done my java micro edition which is for cellphones. All we used was an editor like jedit(j2sdk) with all the api's installed (cant remember what else we installed) then the wireless toolkit. We would code in Jedit then save the .java file int the apps folder in a file that u create the first time u run the wtk (create new project) then in there should be a folder automatically created called src. put the java files in there and run the wtk. click open project. select ur created project. click build then if there r no errors select run. if u wanna see the code that needs to be in the .java file i've still got my hello world! :)
User avatar
StarPhoenix
B.Soc.Sci, M.SocSci [UPCF]
Posts: 17634
Joined: 11 Dec 2003, 02:00
Processor: Core i5 3470
Motherboard: Gigabyte G1 Sniper Z77
Graphics card: nVidia GeForce GTX 1060
Memory: 8Gb DDR3 1600
Location: East London
Contact:

Post by StarPhoenix »

Just what is the difference between a Class and an Object? [Class SurprisedStoat versus Object SurprisedStoat for example]
Thank you
Hex_Rated
Registered User
Posts: 3679
Joined: 19 Jan 2006, 02:00
Contact:

Post by Hex_Rated »

A class defines an object (like a blueprint). An object is an instance of a class.

Code: Select all

public class Hello {

  public Hello (){
  
  }
}

public class MyApp {

  public MyApp() {
    Hello hey = new Hello();
  }

}

Hello is the class, hey is the object.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

supertwit wrote:Just what is the difference between a Class and an Object? [Class SurprisedStoat versus Object SurprisedStoat for example]
Thank you
A class serves as the template of an object. You can only access its member data if it's declared static:

Code: Select all

String name = SurprisedStoat.name; // The 'name' member of SurprisedStoat must be declared static for this to work.
Objects are instances of classes, and you can make as many instances as your memory can cope with.

Code: Select all

SurprisedStoat stoat1 = new SurprisedStoat();
SurprisedStoat stoat2 = new SurprisedStoat();

// stoat1 and stoat2 are objects of the type SurprisedStoat.

stoat1.name = "Jeff";
stoat2.name = "Blazer";

System.out.println (stoat1.name); // Jeff
System.out.println (stoat2.name); // Blazer
(Directly accessing an object's data like this is very poor programming practice, but I use it here just to illustrate the point better.)
User avatar
StarPhoenix
B.Soc.Sci, M.SocSci [UPCF]
Posts: 17634
Joined: 11 Dec 2003, 02:00
Processor: Core i5 3470
Motherboard: Gigabyte G1 Sniper Z77
Graphics card: nVidia GeForce GTX 1060
Memory: 8Gb DDR3 1600
Location: East London
Contact:

Post by StarPhoenix »

So to use the Blueprint analogy, the Class is the blueprint and the Object is the product?
"Humankind cannot bear very much reality." T.S. Elliot
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

supertwit wrote:So to use the Blueprint analogy, the Class is the blueprint and the Object is the product?
Pretty much :wink:
Tiza
Registered User
Posts: 1486
Joined: 01 Dec 2004, 02:00
Location: At your window
Contact:

Post by Tiza »

Hey GUys.


Say you have the word "Johndan" as a String?

How would you reverse the order of the word so it says "nadnhoj"?

I think u break the word up into seperate letters, and then put it back togeather in the reverse order...

How would you do this?

Using a nested for loop or what?

Thanks
Image
I am a guy so please people stop sending me these shady pm's and start playing computer games or bodybuilding. Forums aren't a good place to get chicks the gym is...
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

Code: Select all

public String reverse(String input){
   if(input==null||input.length()==0)
     return "";

   String retval = "";
   for(int i = input.length()-1;i>=0;i--)
        retval += input.charAt(i);
   return retval;
}
is just one of the approaches you could take... the other options include breaking the originating string into a char array and traversing the array in reverse... (String class has a toCharArray() method).
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Moses
Registered User
Posts: 2545
Joined: 21 Jul 2004, 02:00
Location: Location:
Contact:

Post by Moses »

EDIT: rustypup beat me to it.

psuedo code:

new_string = ""

for i = 0 to length(string)-1

new_string = length(string) - i
Post Reply