943,902 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1693
  • Java RSS
Aug 16th, 2007
0

Please Help me......error in compiling

Expand Post »
im trying to compile a java file in my computer...and it wil not work...its my first time doin it here...

my problem was..i cant compile any java file...


this will only appear


java.lang.NoClassDefFoundError: mynote/java
Exception in thread "main"
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javakeith is offline Offline
4 posts
since Aug 2007
Aug 16th, 2007
0

Re: Please Help me......error in compiling

This is due to a missing or incorrect classpath. Classpath tells where to find the files required to compile your program. You specify it by either setting an environment variable CLASSPATH or by using the -cp switch on the javac command:
Java Syntax (Toggle Plain Text)
  1. javac -cp ./;c:/myProjectDir;c:/otherFilesDir MyProgram.java
If it is a single file with no other dependencies, you can compile it from within the directory containing the java file without setting the classpath, but you will need to have the jdk/bin directory on your system path or use the full path to javac to invoke it.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Aug 18th, 2007
0

Re: Please Help me......error in compiling

hello can i ask for a help....i dont know how to continue with my project..please help me with this..i my project is to make a sample editor that counts the characters, consonants, vowels,symbols and spaces..can u please help me with this...my code as of now..still the layout..


import java.awt.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.util.*;


public class gui2 extends JFrame
{
private static final int WIDTH = 1500;
private static final int HEIGHT = 1500;

private JLabel characL, vowL, consoL, spacesL, symL;
private JTextField characTF, vowTF, consoTF, spacesTF, symTF;
private JTextArea ATA;


public gui2()
{
characL = new JLabel("Characters:", SwingConstants.LEFT);
vowL = new JLabel("Vowels: ", SwingConstants.LEFT);
consoL = new JLabel("Consonants: ", SwingConstants.LEFT);
spacesL = new JLabel("Spaces:", SwingConstants.LEFT);
symL = new JLabel("Symbols:", SwingConstants.LEFT);

characTF = new JTextField(20);
vowTF = new JTextField(20);
consoTF = new JTextField(20);
spacesTF = new JTextField(20);
symTF = new JTextField(20);

ATA = new JTextArea();
setTitle("Jesse's Text Editor");
Container pane = getContentPane();

setLayout(null);

pane.add(ATA);
pane.add(characL);
pane.add(characTF);
pane.add(vowL);
pane.add(vowTF);
pane.add(consoL);
pane.add(consoTF);
pane.add(spacesL);
pane.add(spacesTF);
pane.add(symL);
pane.add(symTF);


ATA.setSize(1000,600);
characL.setSize(100,50);
characTF.setSize(75,50);
vowL.setSize(100,50);
vowTF.setSize(75,50);
consoL.setSize(100,50);
consoTF.setSize(75,50);
spacesL.setSize(100,50);
spacesTF.setSize(75,50);
symL.setSize(100,50);
symTF.setSize(75,50);

ATA.setLocation(80,20);
characL.setLocation(1,700);
characTF.setLocation(80,700);
vowL.setLocation(200,700);
vowTF.setLocation(300,700);
consoL.setLocation(400,700);
consoTF.setLocation(500,700);
spacesL.setLocation(600,700);
spacesTF.setLocation(700,700);
symL.setLocation(800,700);
symTF.setLocation(900,700);

ATA.setBorder(BorderFactory.createLineBorder(Color.black));
ATA.setColumns(50);
ATA.setRows(20);

setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new gui2();
}

}




the code is not good..^^but it runs..still the layout...
Last edited by javakeith; Aug 18th, 2007 at 1:16 pm. Reason: forgot something
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javakeith is offline Offline
4 posts
since Aug 2007
Aug 18th, 2007
0

Re: Please Help me......error in compiling

NoClassDefFound isn't thrown from the compiler, only from the runtime...

So you probably did not in fact compile your class, or indeed forgot to include it on the classpath when trying to execute it.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Aug 18th, 2007
0

Re: Please Help me......error in compiling

how can i get the result from a TextArea and place it on a TextField??....anyone who knows?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
javakeith is offline Offline
4 posts
since Aug 2007
Aug 21st, 2007
0

Re: Please Help me......error in compiling

getSelectedText(); setText(); should do the trick.
just go through the api's
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is offline Offline
2,497 posts
since Jan 2007
Aug 22nd, 2007
0

Re: Please Help me......error in compiling

DO AS FOLLOWING FOR SETTING CLASSPATH:

Setting classpath in jdk 1.6.0




1. install the JDK1.6 from the installation directory
2. Please keep the default path of installation while installing the JDK
generally it would be in the "program files" directory of
System drive. If the system drive is C: then
JDK would be installed at c:\program files\java\jdk1.6 folder

3. right click on "my computer" icon on the desktop.
4. click the property sub menu
5. click the "advanced" tag on the dialog box
6. click on "environment parameters"
7. a dialog box will appear.
look for "system variables" list at the bottom of the dialog box.
8. find out the parameter "path" in the list
9. after selecting the path, click on the edit button
10.a message box will appear with the name "path" and current path value in the bottom text box.
11. append the path of java bin folder with the existing path
the path of java bin folder would be (is installed with default path )

C:\Program Files\Java\jdk1.6.0\bin
append the above path with the existing path
then click OK
12.Now Look for the classpath parameter in the system variable list again.
if No "classpath" parameter is available then
create a new one by clicking "new" button. In the "variable name"
text box give the name "CLASSPATH" and in the
"variable value" text box give the following (if default installation path is choosen)
;.;C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar
otherwise if the CLASSPATH parameter is already available then
just click the edit button by selecting the existing CLASSPATH and
then append the above CLASSPATH with the exiting one.
click OK

Next

jTextField returns a object
You can get string from jTextField by jTextField.getText.toString()
Last edited by arkaprava; Aug 22nd, 2007 at 2:33 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
arkaprava is offline Offline
34 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Please Help me......error in compiling

set path of java home directory and bin directory separately in environment variable
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sat11 is offline Offline
1 posts
since Aug 2007
Aug 25th, 2007
0

Re: Please Help me......error in compiling

problem in main

should be

public static void main(String[]args)
{
gui2 myprogram=new gui2();
myprogram.setVisible(true);
myprogram.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myprogram.setSize(blah2,blah2);
}
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Changing the icons of JButtons
Next Thread in Java Forum Timeline: problem in accessin table values from access database..





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC