Head First Java BeatBox - Won't Compile
May 1, 2011
I am totally new to programming in every way, shape or form, and I'm working my way through the Head First Java book (2nd ed). I have just finished copying the code for the initial BeatBox app, the one starting on page 420. When I try to compile it, I get these errors:
BeatBox.java:36: cannot find symbol
symbol : constructor Box(int)
location: class Box
Box buttonBox = new Box(BoxLayout.Y_AXIS);
^
BeatBox.java:40: cannot find symbol
symbol : method add(javax.swing.JButton)
location: class Box
buttonBox.add(start);
[code]....
I doubt that this is relevant, but I'm running Mac OS X, coding in TextWrangler and compiling with Terminal. Java version is 1.6.0_24.
View Replies
ADVERTISEMENT
Mar 24, 2015
I'm currently reading Head First Java and want to use the topics shown in the book while I read it to master them. What are some good projects that can be used to practice all the skills taught in the Head First Java book while I read it?
View Replies
View Related
Jan 2, 2015
I downloaded this code from Head First Java. But when I tried running it on Eclipse, it gives this error message.
import javax.sound.midi.*;
public class MiniMiniMusicApp { // this is the first one
public static void main(String[] args) {
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
[code]....
and this was the error message: Jan 02, 2015 8:10:36 PM java.util.prefs.WindowsPreferences <init>Could not open/create prefs root node Software Java SoftPrefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
View Replies
View Related
Jun 27, 2014
I'm facing another problem with the HFJ code which i edited some what (as given HFJ) to make it work through command line..BeatBox using command line. Getting compiled but no sound coming..
package com.BB.getPlayer;
import javax.sound.midi.*;
public class MiniMusicAppCmd {
public static void main(String[] args) {
// TODO Auto-generated method stub
[code]....
View Replies
View Related
Oct 10, 2014
I'v tried everything, i'v tried to create new path in enviornment variables i tried adding this path -->(C:Program FilesJavajdk1.8.0_20bin) to the end of the default path doesnt work i uninstalled and reinstalled and did the same thing over and it didnt work am i editing the files wrong ? what i do is write the hello world program in eclipse to make sure there arent any errors then copy and paste in note pad++ save it as a .java file and it doesnt work i tried save it in regular notepad as .java laso and it doesnt work iv done every thing i could possibly find on youtube is this stuff outdated ? is there a new way? this one one of the errors ill get
C:javat>javac helloworld.java
helloworld.java:1: error: '{' exp
public class helloworld.java {
^
And this is the code for that file im trying to compile
public class helloworld.java {
public static void main (String args[]){
System.out.println("hello world");
}
}
View Replies
View Related
Jan 26, 2014
How do I set the class path, the path, compile and run java programs using jdk and jcreator?
View Replies
View Related
Jan 22, 2014
I made just a simple hello world class and i can not seam to make eclipse run it in any way not even the console.
View Replies
View Related
Mar 7, 2014
Why can't I see the text when I compile the java code?
Java Code:
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
public class WorldTravel {
public static void main (String[] args){
JFrame f = new JFrame("World Travel!");
BG_text p = new BG_text();
[Code] ....
View Replies
View Related
Dec 23, 2014
i wrote this program:
class hellojava
{
public static void main(string[] args)
{
system.out.println("hello java");
}
}
Then i saved this file with name hellojava.java(notepad) in C drive in separate folder c:myjavaapp(not in c:java folder).
When I am compiling(with javac hellojava.java) it shows following error:
cannot find symbol public static void main(string[] args), and also says package system doesnot exists system.out.println("hello java");
View Replies
View Related
Feb 14, 2014
I am looking for a way to compile Java Source-Files at runtime and save them all in an executable jar; almost like an IDE would do. I know that there is the javax.tools package which provides a JavaCompiler interface and you can use ToolProvider.getSystemJavaCompiler() to get an instance of a compiler. However, this method has one important problem: it only works on machines that have the JDK installed. Not when only the JRE is installed.
I guess at this point that I need some kind of third party library that offers an implementation of a JavaCompiler. Unfortunately, this is really complicated to search for on the internet since all top listings when searching "compile java at runtime jre" do not really provide a solution to the problem.
I am writing a (somewhat) complex simulation software right now which is supposed to be used by people who have absolutely no knowledge of programming. At the same time, this software should provide the user with a certain amount of flexibility and control over the flow of the simulation.
My previous take on this problem was to build a complex system to interprete user settings from a GUI. I would basically read the GUI input, output it to some kind of own scripting syntax which I just quickly made up and have that interpreted at runtime. Then I realized, that is a silly concept and I threw it out before I got far into the developement.
The much better solution I came up with is taking the input from the GUI, create java source code from it and compile it at run-time. Seems much cleaner and nicer to me; will also probably have a better performance, but thats not really an issue anyways.
View Replies
View Related
Jan 20, 2015
on my computer, i have configured the environment variables as
CATALINA_HOME : D:apache-tomcat-8.0.9-windows-x64apache-tomcat-8.0.9;
CLASSPATH : D:apache-tomcat-8.0.9-windows-x64apache-tomcat-8.0.9libservlet-api.jar;D:apache-tomcat-8.0.9-windows-x64apache-tomcat-8.0.9libjsp-api.jar;.;
JAVA_HOME : C:Program FilesJavajdk1.8.0_05
path : D:apache-tomcat-8.0.9-windows-x64apache-tomcat-8.0.9in
In reference to the book "Head First Servlets and JSP, 2nd edition", chapter-3(), page-81, the command to compile the servlet file to the desired location is
javac -classpath UsersertApplications2 omcatcommonlibservlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java (from the Myprojects/beer-V1 directory)
Whereas I have written
javac -classpath D:apache-tomcat-8.0.9-windows-x64apache-tomcat-8.0.9libservlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java
(from the same directory as can be confirmed from the attachment of screenshot of error). this code is in accordance to the location of the respective files in my system, in particular the servlet-api.jar file.
After doing this, my computer is showing the error : file not found.
How do I resolve this? Actually, I don't understand completely what this code is trying to accomplish.
View Replies
View Related
Nov 25, 2014
I keep getting this error when compiling the code . I think its got to do with the Tomcat server not working well with the textpad app...I'm using windows 8.1(for the course I have to use Textpad 4.7.3 & Apache Tomcat 5.5.7 Server) :
C:UsersReignDownloadsIntec - Codecourse technology59850dChapter 12WorkWebStocks.java:20: package javax.servlet does not exist
import javax.servlet.*;
^
C:UsersReignDownloadsIntec - Codecourse technology59850dChapter 12WorkWebStocks.java:21: package javax.servlet.http does not exist
import javax.servlet.http.*;
[code]....
tom cat is running as a service it shows started in the tom cat app and as a running service in windows services !!!
View Replies
View Related
Apr 18, 2014
I'm having problems with the public static void main(String args[]) part. Everything else is correct before this, my teacher has checked that. I have been trying to research why it won't compile right and can't find any errors.
/*
Chapter 6:Telephone
Purpose:This project displays a telephone keypad you can use to type in a phone number.
*/
import java.awt.*;
import java.datatransfer.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class Telephone extends Frame implements ActionListener
[Code] ....
View Replies
View Related
Jan 11, 2014
I was reading head first java and the author told to read head first design pattern next.
View Replies
View Related
May 17, 2014
I am trying to compile multiple jar files into one jar file from inside a java program. I know how to do this with shell scripts but I would rather have a universal application than one that will only run on Mac, Windows, or Linux. This is my current compiler code:
if(System.getProperty() == "Mac OS X"){
Runtime.getRuntime().exec("javac -classpath jar1.jar; jar2.jar");
}
I would then continue this on for Linux and Windows, but this limits my application.
View Replies
View Related
Sep 3, 2003
I want to call the HEAD method on a servlet.If in my HTML code, I specify -
<form name="testHead" action="/servlet/servletName" method="HEAD">
And the servlet handles the HEAD method in the sense that the doGet() method returns if the method type is HEAD.When I run it, the servlet returns the code returned by the entire doGet() method. This shows that the doGet() method does not realize that it is a HEAD method and it should return back without processing further.The application server is Tomcat 4.0.
View Replies
View Related
Jul 29, 2013
class SubB{
public void foo(){
System.out.println(" x");
}
}
public class X extends SubB {
public void foo() throws RuntimeException{
super.foo();
if(true) throw new RuntimeException();
System.out.println(" B");
}
public static void main(String [] args){
new X().foo();
}
}
Why the foo method of class X is not throwing a compile error because according to the override rule, if the superclass method has not declared exception, the subclass method can't declare a new exception...
View Replies
View Related
May 25, 2014
am trying to Develop a download manager that will improve the downloading process, by splitting big files into different parts, and download each part of the file parallel and then combine them properly Just like JDownloader not really too complex like it though but more like it especially the split download part of it. I was able to get a script from some eBook but that doesn't really solve my problem as it only downloads pause and resumes which is not really what am looking for.
View Replies
View Related
Apr 16, 2014
I am creating a chained hash table that uses my own LinkedListclass to handle collisons. Here is where my issue is occuring: I start with an array of LinkedLists, my "hash table", intially set to null. When i wish to add a word, if the desired location is null, I create a new LinkedList, place it in that array index. I then create a new LinkedListNode and set the head of the new LinkedList to the new node.
My issue is occuring here: Whenever I set the head of my new LinkedList to my new LinkedListNode all of my previously created linkedlists also have their head changed to the new node.
My debugger shows that I am truly creating new linkedlists every time. I was afraid each array index was just pointing to a single array, but that is evidently not the issue. Below is all the relevant code
public class SetOfStrings {
private int arraySize;
private LinkedList[] mainArray;
private int totalCount;
//other methods here
public boolean add(String toAdd) {
int hashToAdd = hash(toAdd);
[code]....
SUMMARY: Whenever I set the head of a Linked List to a new node, it changes the head of all my linked lists to point to the same new node
View Replies
View Related
Mar 26, 2014
I am trying to flip a coin 1000 times and make the driver class count the number of times a head and tails appear. However, I am having some trouble trying to figure out the error:
package Week5;
import java.util.Random;
public class Coin {
private int heads;
private int tails;
private int face;
[Code] ....
I was able to print out the generated numbers, but java will print either heads or tails a thousand times and count that as 1000 and nil for the other probability...
View Replies
View Related
Mar 18, 2014
Write a class named FileDisplay with the following methods:
1.) constructor: the class's constructor should take the name of a fil as an arugment.
2.) displayHead: This method should display only the first five lines of the file's contents
Here is the following code I have made so far
import java.io.*;
public class FileDisplay
{
private String filename;
public FileDisplay(String Filename) throws IOException
[Code] ....
First, in my constructor I have taken in an argument and used that argument to open up an output file. Meanwhile, I'm trying to work n the displayhead method to print out information and to read data to. I haven't opened up my input file yet, but I'm not understand how can I read a print data to an output file. in
public void displayHead()
{FileWriter file=new FileWriter(Filename)}
do I make create another instance of the filewriter class to output data?
In simple words, suppose to I want to display some messages on my output file in the displayhead function. Since I already have opened up the file in the constructor, how do I combine that in this method...
View Replies
View Related
Feb 20, 2014
I'm creating a program that will compile and run another java program:Lets say I have a program in directory
D:HelloWorldsrc
and compiled program will be in
D:HelloWorldin
inside src and bin is a folder hello (that's a package)
package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Hello World");
}
}
This program will be run by another program (that's the program that I am creating).Here is the code of my program:
package runnercompiler;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class RunnerCompiler {
[code]....
View Replies
View Related
May 6, 2014
I'm doing a project and my code won't compile.
import javax.swing.*;
import java.awt.event.*;
public class BookStore extends JFrame{
private JPanel panel;
private JLabel question; //This will be where the question is.
private JTextField NumofBooks; //this is where the user will enter the number of books
private JButton OKButton,ClearButton,ExitButton; //Will give the user the points, cancel the points, and exit
private final int WINDOW_WIDTH = 310; //Need to make it visible
private final int WINDOW_HEIGHT = 100;
[code]....
View Replies
View Related
Mar 5, 2015
i would like to ask what does exactly do the command mvn compile. What is happening with the code, when i write this command? And why is it necessary for running the code?
View Replies
View Related
May 15, 2014
This is my TagHandler class
package foo;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
[Code] ....
But it is not able to find all the classes referenced in the code. While compiling I am mentioning the servlet-api.jar
My compilation statement is this
C:Tomcat 7.0webappsSimpleCustomTagsWEB-INF>javac -cp "C:Tomcat 7.0libservlet-api.jar;.;" classesfoo*.java
It says package javax.servlet.jsp.JspException and javax.servlet.jsp.tagext.SimpleTagSupport does not exist.
View Replies
View Related
Apr 1, 2015
I created Myproject folder. Inside I have 3 folders:
/lib
/src
/bin
Inside src there is a .java file:
public class hello_world{
public static void main(String[] args){
System.out.println("Hi, from hello_world");
seba.st.hello_world_package test1 = new seba.st.hello_world_package();
test1.packFunc();
}
}
inside lib is a packEx.jar file which I created from this .java file:
package seba.st;
public class hello_world_package{
public void packFunc(){
System.out.println("hi from pack_func!");
}
}
I am trying to run this program from terminal with this command
javac -d bin -sourcepath src -cp lib/packEx.jar src/hello_world.java
and I get this error:
src/hello_world.java:11: error: cannot find symbol
test1.packFunc();
^
symbol: method packFunc()
location: variable test1 of type hello_world_package
1 error
What am I doing wrong ? How can I compile and run this program from terminal?
View Replies
View Related