And Green

Greenhorn
+ Follow
since Sep 28, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by And Green

Henry Wong wrote:
It may also help if you provided more details, such as... do you have a CLASSPATH set? How are you compiling it? And the exact output of the error messages.

Henry



It was the classpath! Many thanks Henry and sorry to trouble you (and anyone else) with this.

(embarassed emoticon)
13 years ago
Yes I have Pete unfortunately.

Thanks for posting though
13 years ago
Hello all.

Got a new problem. I'm guessing it's basic but I'm at the point I need some help.

I'm currently writing new classes and compiling them successfully, when I try to reference the new class types in a main method (in a separate file but same directory) the main method cannot find my new classes and will not compile.

("cannot find symbol class: <classname>")

Both classes/files are in the same directory. Neither file belongs to any package.

My PATH environment variable seems to be OK, because the new classes compile OK, they just can't be used by other classes or files in the same directory.

Any ideas? (I'm imagining the answer may be quite embarassingly obvious!)
13 years ago

Ulf Dittmer wrote:Just to make sure: is any program associated with MP3s? That is to say, if you double-click that file, does WMP open?



Yes, WMP opens when an mp3 or wma is clicked. The strange thing is, the above program works with mp4 video and this is opened with WMP, no problem
15 years ago

Ulf Dittmer wrote:Look at the javadocs of that class - the constructor isn't listed, because it's not public. You can obtain a Desktop object via

Desktop mediaplayer = Desktop.getDesktop()

Note that this will not work when run in an IDE; that's what the Desktop.isDesktopSupported() method guards against.



I get you, yes thanks.

I wondered if anyone has been having a simalar problem to this. I am getting a runtime error now. the program can open documents but not mp3's:

import java.io.*;
import java.awt.*;

public class music {

public static void main (String [] args)throws Exception {

File tester = new File("C:/etc/etc/asong.mp3");

Desktop mediaplayer = Desktop.getDesktop();

mediaplayer.open(tester);

}

}

Error on cmd line given as :

Failed to open file Invalid menu handle

at sun.awt.windows.WDEsktopPeer.ShellExecute(WDesktopPeer.java:59)
at sun.awt.windows.WDEsktopPeer.open(WDesktopPeer.java:36)
at java.awt.Desktop.open(desktop.jav:254)
at music.main(music.java:14)


Banging head against brick wall error!

15 years ago

Rob Prime wrote:It is part of the standard Java APIs, but not until Java 6.
http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html

If you're using Java 5.0 or before you have to find alternatives.



Cheers for that. It looks promising. If I try to create an object of type Desktop ie :

Desktop mediaplayer = new Desktop();

and then call the open method on it, it gives me the error:

Desktop() has private access in java.awt.Desktop

and it points to the new keyword as the cause of the problem.

I've never come accross anything like this before, any ideas most appreciated!

15 years ago

Rob Prime wrote:java.awt.Desktop.open(File) should do the trick. Otherwise you can create a process for

This only works on Windows though.



Hello, thanks for that Rob, but I am unfamiliar with the package java.awt.Desktop. It is not part of the standard java 5 or 6 api's, is it a package I need to download from somewhere?

Regards.
15 years ago
Am looking for tips on executing an mp3 file using java.

My current application searches relevant directories and creates jbuttons for each song in the directory. What I am looking to do next is for when a user clicks on a button, the relevant mp3 file is played via the default media player (ie Windows media player).

Anyone have any tips on how this may be achieved using the Java 5 API?

Thanks in advance (apologies if this is impossible!)

15 years ago
This question will probably make the more experienced users of servlets laugh due it's simplicity/stupidity!

If my form action in an HTML page is :

<FORM ACTION="/servlet/HelloYall">

and my servlet is in the directory:

apache_install_dir\Tomcat 5.5\webapps\ROOT\WEB-INF\classes

Where should I run my HTML from, for the path to the servlet to be valid?

Thanks in advance!
15 years ago
This question will probably make the more experienced users of Tomcat laugh due it's simplicity/stupidity!

If my form action in an HTML page is :

<FORM ACTION="/servlet/HelloYall">

and my servlet is in the directory:

apache_install_dir\Tomcat 5.5\webapps\ROOT\WEB-INF\classes

Where should I run my HTML from, for the path to the servlet to be valid?

Thanks in advance!
15 years ago
Firstly, forgive my ignorance at the outset if this is an obvious and/or stupid question!

I have created a free standing java application which is basically a frame with some buttons in it:

import java.awt.*;
import java.awt.event.*;


public class FrameTester
{
public static void main (String[] args)
{
TempFrame frame = new TempFrame();
frame.setTitle("Frame Test");
frame.setVisible(true);

}
}
class TempFrame extends Frame implements ActionListener
{
//TempFrame constructor
public TempFrame()
{
//set framesize
final int DEFAULT_FRAME_WIDTH = 250;
final int DEFAULT_FRAME_HEIGHT = 150;
setSize (DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT);
//Using GridLayout manager
setLayout (new GridLayout(4,2));
setLocation(100,100);
setTitle("Students - Main Menu");

close = new Button("close");
close.addActionListener(this);
add(close);

inputBox = new Button("Input test");
inputBox.addActionListener(this);
add(inputBox);

testDialog = new TestDialog(this);
}


public void actionPerformed(ActionEvent e)
{

if (e.getSource()==close)
System.exit(0);

else if(e.getSource()==inputBox)
testDialog.setVisible(true);
}

private Button close, inputBox;
private Dialog testDialog;

}

class TestDialog extends Dialog implements ActionListener

{
public TestDialog(Frame f)
{
super(f,true);
setSize (600,500);
setTitle ("Test Writer");
setLocation(300,100);
setLayout(new GridLayout(2,2));
add(new Label("general input"));
student_number=new TextField(10);
//student_number.addKeyListener(this);
add(student_number);

clear=new Button("Clear (close!)");
clear.addActionListener(this);
add(clear);
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource()==clear)
System.exit(0);
}


private Button clear;
private TextField student_number;
}

and I want to embed the frame "frame" in a web page.

Is there a way of using JSP (Beans or some other method) to embed this code into a web page, without substantially rewriting my code. Any tips or pointers in the right direction, most appreciated.
16 years ago
Yep, worked a treat. This website is great.
16 years ago
JSP
Thanks alot for that. Very quick too!

I'll give it a go.
16 years ago
JSP
Apologies if this really obvious.

I've just started playing about with JSP on Apache Web Server.

I've managed to get servlets running by placing them in file: Tomcat 6.0\webapps\examples\WEB-INF\classes. What I want to do however is call Java classes that I've constructed myself, for use in JSP scriptlets.

I can't figure out as to where I need to put the compiled classes though, which allows them to be called for use in JSP.

Is their anyone whose familiar with Apache Tomcat able to help?
[ November 02, 2007: Message edited by: Bear Bibeault ]
16 years ago
JSP
I�m currently doing the J2EE tutorial off of Java Sun, and downloaded the Sun Application Server 9.0 which includes the ant download.

I�m having trouble deploying my applications from the command line using Ant though. I�ve set the path variable as per instructions as-install/lib/ant/bin and modified the relevant paths in the bp-project/build.properties file.

When I build the application using the ant command, it builds successfully despite initially stating that its �unable to find tools.jar expecting to find it in jre_1.6.03\lib\tools.jar�.

When I try to deploy it fails completely. It states again it unable to find the tools.jar and that the build .xml does not exist

I am currently able to deploy applications using NetBeans, but I want to get Ant working.

Anyone able to point me in the right direction please. Apologies if I�m doing something wrong that�s obvious.
16 years ago