LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2004, 10:23 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Rep: Reputation: 47
Java, code compiles and supposedly runs fine in windows, but not linux


I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: //MenuBalloon/class

when I run this code that I downloaded from a website, it is part of a book and it says it works in windows and unix. It compiles fine. I also wrote my own program based on it that is completely different and also compiles fine.

http://www.shu.ac.uk/java/3rdEdition...enuBalloon.txt
is the books code

my code is:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class Assign10 extends Frame implements ActionListener, WindowListener
{

private MenuItem New, Open, Delete;
private MenuItem Undo, Redo, Cut, Copy, Paste;
private String TheString = new String("Select a menu item");

public static void main(String[] args)
{
Frame f = new Assign10();
f.setSize(300, 300);
f.setVisible(true);
}

public Assign10()
{
setTitle("MenuThingy :-D");

MenuBar menuBar = new MenuBar();

Menu fileMenu = new Menu("File");
Menu editMenu = new Menu("Edit");

New = new MenuItem("New");
fileMenu.add(New);
New.addActionListener(this);

Open = new MenuItem("Open");
fileMenu.add(Open);
Open.addActionListener(this);

Delete = new MenuItem("Delete");
fileMenu.add(Delete);
Delete.addActionListener(this);


Undo = new MenuItem("Undo");
editMenu.add(Undo);
Undo.addActionListener(this);

Redo = new MenuItem("Redo");
editMenu.add(Redo);
Redo.addActionListener(this);

editMenu.addSeparator();

Cut = new MenuItem("Cut");
editMenu.add(Cut);
Cut.addActionListener(this);

Copy = new MenuItem("Copy");
editMenu.add(Copy);
Copy.addActionListener(this);

Paste = new MenuItem("Paste");
editMenu.add(Paste);
Paste.addActionListener(this);

menuBar.add(fileMenu);
menuBar.add(editMenu);
setMenuBar(menuBar);
addWindowListener(this);
}

public void actionPerformed(ActionEvent event)
{
if (event.getSource() == New)
{
TheString = new String("You Selected New");
}
if (event.getSource() == Open)
{
TheString = new String("You Selected Open");
}
if (event.getSource() == Delete)
{
TheString = new String("You Selected Delete");
}
// MenuItem Undo, Redo, Cut, Copy, Paste;
if (event.getSource() == Undo)
{
TheString = new String("You Selected Undo");
}
if (event.getSource() == Redo)
{
TheString = new String("You Selected Redo");
}
if (event.getSource() == Cut)
{
TheString = new String("You Selected Cut");
}
if (event.getSource() == Copy)
{
TheString = new String("You Selected Copy");
}
if (event.getSource() == Paste)
{
TheString = new String("You Selected Paste");
}
repaint();
}

public void paint (Graphics g)
{
g.drawString(TheString,20,20);
}

public void windowClosing(WindowEvent e)
{
System.exit(0);
}

public void windowIconified(WindowEvent e)
{
}
public void windowOpened(WindowEvent e)
{
}
public void windowClosed(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
}

i compile with javac ./filename.java
 
Old 03-13-2004, 10:39 PM   #2
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
lol strange ./ was the problem?
 
Old 03-14-2004, 10:19 PM   #3
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
Quote:
Originally posted by exodist
no wait.. I think I will need a lot of secs
haha I need a lot of secs too... but I can never find the women to provide it
 
Old 03-16-2004, 12:02 PM   #4
lucasbl3
LQ Newbie
 
Registered: Feb 2004
Posts: 8

Rep: Reputation: 0
I donīt think there is a problem in the code but rather in the command you use for invoking it.
Could you send the exact command line that you use for running this program (with all the arguments) ?
 
Old 03-16-2004, 12:47 PM   #5
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
I already clarified, I used java ./whatever.class, the ./ was the problem, so was the .class, I had to type java whatever
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C code compiles on windows, but not with gcc MDBlueIce Programming 6 05-23-2005 04:33 PM
Most Java runs fine, one game is slow Brain Drop Linux - Software 0 08-10-2004 10:10 AM
G++ compiles fine but program does not work MaddDog696 Programming 3 04-15-2004 05:39 PM
RedHat 9.0, Kernel 2.4.21, Linux-Wlan-Ng-0.2.1, Compiles and Runs. But Cant Connect. AndrewBalmos Linux - Wireless Networking 5 01-18-2004 06:18 PM
compiles fine but a make error bosewicht Linux - Newbie 3 01-04-2004 06:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration