How to Run a Compiled Component

I am sooo new to JAVA. I bought a book (O'Reilly) to learn Java. I loaded the JAVA complier and the JAVA run time (1.5). I also loaded an IDE called Eclipse. I tried to run some of their example code, but it wouldn't work - this is the error I got "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Enum. Fix the build path then try building this project     LearningJava               August 11, 2006 4:16:35 PM"
So I tried to use the command line to run basic JAVA. I have a simple program from the book - "HelloJava". I got it to compile with javac command, but when I go to "run" this with the java command, this is the message that I receive
"Exception in thread "main" java.lang.NoClassDefFoundError:" which kind of sounds like I am missing something - same as with Eclipse message above.
I have reloaded everything two times - what can I be doing wrong.
This is supposed to be simple? But I can't even get the sample programs to run. Here is the sample program I did get to compile:
public class HelloJava
public static void main( String[] args ) {
     System.out.println("Hello, Java!");
public class HelloJava
public static void main( String[] args ) {
javax.swing.JFrame frame = new javax.swing.JFrame( "Hello, Java!" );
frame.setSize( 300, 300 );
frame.setVisible( true );
import javax.swing.*;
public class HelloJava
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
     JLabel label = new JLabel("Hello, Java!", JLabel.CENTER );
frame.getContentPane().add( label );
frame.setSize( 300, 300 );
frame.setVisible( true );
import javax.swing.*;
public class HelloJava
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
frame.add( new HelloComponent() );
frame.setSize( 300, 300 );
frame.setVisible( true );
class HelloComponent extends JComponent {
public void paintComponent( java.awt.Graphics g ) {
g.drawString( "Hello, Java!", 125, 95 );
Why can't I get this to execute??? Thank you!!!

remove the CLASSPATH setting which might have been set by
Eclipse or other tools.
on windows platform before compiling and running from the command
prompt give the command
SET CLASSPATH=
to clear any CLASSPATH setting.

Similar Messages

  • How to run and compile a java servlet on Tomcat?

    Hi, I am very new to servlets in Tomact.
    I went to the java tutorial and from the address below I copy an example (SimpleServlet).I try to run and compile it in Tomcat, But I don't know how can I do that. I appreciate if somebody tell me the command line for compiling and running this example and the necassary steps. (My Tomcat is installed perfactly).
    http://java.sun.com/docs/books/tutorial/servlets/overview/simple.html
    Thankx

    Hello,
    I have the similar question.
    Instead of going thru sun's tutorial, I tried onjava's ("http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html?page=1").
    I could see the jsp page, but when I tried to add a servlet, I got an error "Page not found". I followed exactly the same way they describe. The only thing I noticed was the resulting page on the tutorial had the URL of ".../servlet/...".
    Is this "servlet" directory something we are supposed to create our own? If so, under what directory? Or do we need to set up anything in order for the servlet to be referenced that way?
    Thanks in advance.

  • How to run the compiled wedforms to browser?

    Ladies and gentlemen,
    Kindly give me the a sample command on how to run the forms in
    the browser.
    Billy,
    null

    I have the same problem , the mini virus is so slow and unpredictable it is a joke.
    There is no way to disable it.

  • How to Run and Compile by using J2SE?

    Title says it all. Any patch file? or any command in command prompt to run or compile.
    thanks,

    Hey u will have to download j2se in order to run and compile java programs.you can download the latest version of j2se1.4 from this site it sels the url is http://java.sun.com/j2se .then u install it using the default settings and det the system path to C:\jdk<version-number>\bin thats the place where java.exe and javac.exe lies .To compile type javac <file_name>.java and to execute java <file_name> and yet if u have neprobs mail me at [email protected]

  • How to run and compile servlets using tomcat4.0.3

    Hello
    I have simple servlet "HelloWorld".I have doubts in compiling and running this servlet.I'm using server Tomcat 4.0.3 as and JDK1.3.
    1)where do i need to save this servlet?
    2)how to compile this servlet by setting a classpath?
    3)how do i run this after compilation?
    4)do i need any HTML page to run on browser?.if, so how do i have a reference of servlet in HTML page?
    HERE IS THE SIMPLE SERVLET
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("</body>");
    out.println("</html>");
    Thanx for help

    put your helloworld servlet inside of webapps/example/WEB-INF/classes...
    and then start your tomcat..and type
    http://localhost:8080/webapps/servlet/HelloWorld
    S

  • How  to run  and compile servlet

    hi
    m beginner to servlets
    so please help me how to compile nd run the servlets on notepad.
    i dnt no where to save the servlets nd how to compile nd run it
    thanks in advance

    These links may help you
    http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-First-Servlets.html
    http://www.coreservlets.com/Apache-Tomcat-Tutorial/
    -Mani

  • How to run a compiled file that needs a jar

    Hi all
    I'm trying to run a file that I've compiled that requires a jar
    I have both the jar and java file in the same directory
    HelloWorld.java
    itext.jar
    i compile using
    javac -cp itext.jar HelloWorld.java
    which produces my HelloWorld.class
    but when i run
    java HelloWorld
    I get loads of errors
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorl
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Sourc
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    am i doing something wrong with trying to run the class with the jar file?

    Didnt work
    C:\Projects\pdf>java -cp .;itext.jar HelloWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/lowagie/examples/general/HelloWorld)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

  • How to run .rep (compiled report) from dev10g

    Hello,
    Following code runs report that is .rdf what if i want to print run .rep report??
    declare
    repid report_object;
    v_rep varchar2(100);
    begin
    repid := find_report_object('test');
    v_rep := RUN_REPORT_OBJECT(repid);
    end;
    Regards,
    Edited by: Anwar hussain on Jan 9, 2010 1:09 AM

    Hello,
    The code you have provided can run .rdf or .rep
    It depends if you provide the extension in the Reports Filename .
    If you don't provide an extension (.rep , .rdf ) in the Reports Filename , Reports will use some rules for its search :
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/cmdline/common/bld_modulereport.htm
    If you do not enter a file extension, the executable searches first for a file with extension .rep, then extension .rdf, then .jsp, and then no extension, using the file path search order to find the file.
    Regards

  • How to run 10g compiled form from desktop runtime icon from any machine

    i am facing a prob that is i have installed 10g database / Developer suite ,
    now i created a form on DS which is running fine with in the environment on DS but now prob is
    when i run this form from Desktop its failed to run and generate an error with creating a .err file and give a message that is file not generated ,
    does any one can tell me what is the method of configuration for 10g forms to run it from clioent side ,
    now i have also installed its application server too but what should do now to run it in browser environment from client desktop
    wiating for Reply
    Qaiser Hassan Awan

    Please go to http://forums.oracle.com/forums/index.jspa?categoryID=1 and look for a forum that will discuss forms.
    cu
    Andreas

  • How to run the form that is only installed on a PC and not using a server?

    Hi
    I am new to Oracle and have taken the forms class. But I do not understand how to run the form from my PC using XP windows. (Do not have access to a server).
    I have started the OC4J, made sure the listener was started, compiled the form and then when I run it, it automatically goes to the HTTP:
    ERROR: res://ieframe.dll/acr_depnx_error.htm#,http://kevin:8889/forms/frmservle
    I connected to the database correctly. I can process a report and it does nor try to access the internet. My only issue is running the form. I verified it compiled.
    Sorry for a basic question. Could someone please help, I tried reviewing other questions, but not sure if they are connecting to a server or not.
    I see webutil but is it required if I don't have a server? Thank you in advance.

    Regardless of the version, it appears that you may not have configured the Builder. Do the following:
    1. Open the Builder
    2. From the menu, select Edit > Preferences > Runtime
    3. In the box labeled "Application Server URL:", enter a local URL needed to run a form OR click the button labeled "Reset to Default". If you decide to manually enter a value, it would looks something like this:
    http://localhost:8889/forms/frmservlet
    4. In the field labeled "Web Browser Location:", enter the path and executable to your preferred browser. So for example if IE is your browser of choice the entry would most likely look like this:
    C:\Program Files\Internet Explorer\IEXPLORE.EXE
    5. Click on OK and retest.
    By the way, you can manually enter a URL in the browser. Clicking the RunForm button from the Builder is strictly optional. To run the "test" form directly from the browser enter the following into the browser's address field:
    http://localhost:8889/forms/frmservlet?form=test
    More information about Forms can be found on OTN:
    http://www.oracle.com/technology/products/forms/index.html

  • NAV 2013 R2; How to run a customized report (206 sales invoice) in the classic client

    Hello, in preparing a newly installed NAV 2013 R2, I'm questioning the following:
    In the Development Environment I have customized report 206 Sales - Invoice in the Design menu View Layout with the space of the logo (by Microsoft SQL Server Report Builder) and
    finally saved and compiled.
    When I do run it connects to the server of what I call the classic client or the real NAV 2013 R2 and I can select a posted sales invoice to show the new layout and the result is
    fine as customized as I wanted.
    When I later ordinary print one of the posted sales invoices this customized logo layout doesn't appear on the print. I print in PDF and paper. When I make a next new sales invoice
    this new layout is not in use either.
    Another thing is run print started from the Development Environment is called Sales - Invoice in the header and not just Invoice that it the name when printing when invoicing and
    printing of posted documents.
    Additionally this form of Sales - Invoice shows our company details and good information as web, e-mail, bank account and bank name that is well demanded on a perfect invoice.
    How to get these informations out normally?
    Is the classic client having a wrong report as sales invoice?
    How to run a customized report (206 sales invoice) in the classic client NAV 2013 R2?
    It is like the customized report (206 sales invoice) is not in use yet in the classic client.
    All you wise people out there are welcomed to help me now
    Best regards
    Carsten

    Try on Dynamics Community forum: https://community.dynamics.com/nav/f/34.aspx

  • How to run JavaFX jar with JRE7 on MAC OS Lion 10.7.5 ?

    I have created a bundled JavaFX application jar with ANT on Windows 8 O.S. , 64 bit machine. I have JavaFx2.0 and Java 1.7.0_09 installed on my Window O.S.
    <target name="CreatingJars" depends="Compiling" description="generate the distribution" >
                        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"     
                                 uri="javafx:com.sun.javafx.tools.ant" classpath="${env.JAVA_HOME}/lib/ant-javafx.jar"/>
                              <mkdir dir="${WorkingFolder}/temp/libs"/>
                             <copy todir="${WorkingFolder}/temp/libs">
                             <fileset file="${WorkingFolder}/CustomJars/ProjectLib.jar">
                             </fileset>
                             </copy>
                             <copy todir="${WorkingFolder}/temp/libs">
                             <fileset dir="${WorkingFolder}/libs">
                             </fileset>
                        </copy>
                        <fx:jar destfile="${WorkingFolder}/${app.name}.jar">
                        <fx:application mainClass="${main.class}"/>
                        <fx:resources>
                             <fx:fileset dir="${WorkingFolder}/temp/"/>
                        </fx:resources>
                        <fileset dir="${WorkingFolder}/build"/>
                        <fileset dir="${WorkingFolder}/resources"/>
                        </fx:jar>
         </target> When I am trying to run that JavaFX application jar on MAC OS Lion 10.7.5 using
    java -jar application.jar
    It always shows a dialog "The application require a newer version of Java Run-time" with download link. Even I have downloaded and successfully installed it on my MAC machine but it still shows me the same window.
    java -version is always point to 1.6.
    Then I searched for Java Preferences to point the current JRE 1.7 but I could find Java Preferences at Applications -> Utilities -> Java -> Java Preferences.
    I would like to know -- how to run JavaFX jar with JRE7 on MAC OS Lion 10.7.5? Is their any other way to run the JavaFX application JAR with JRE7?

    Do I need to download the whole JAVA 1.7 on MAC to run the JAR? No
    Can not I run the Jar file with Jre7?Yes, you can.
    This may be because I have downloaded the JRE 1.7Yep, that's correct, the java_home command only works for jdk's - sorry for the confusion.
    For jre7+ versions, only a single Oracle jre version is allowed to be installed on the machine at a time - making a tool like java_home redundant for jre checking.
    Weirdly, jre7u10 does not supplant the Apple Java on the command line path by default. If you just type java -v, then the Apple java version will displayed if you have an old Java 6 from Apple and a new Oracle jre7+.
    The Oracle jre is always located under (also somewhat strangely):
    /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/javaTo test jar launching, I used the willow JavaFX browser pre-release jar available here:
    http://code.google.com/p/willow-browser/downloads/detail?name=Willow-0.1-prerelease.jar
    Then I launched the jar from the command line using:
    /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -jar Willow-0.1-prerelease.jar The JavaFX jar ran fine on jre7 with the above machine.
    The test machine was running Mac OS X 8 with Oracle jre7u10 installed as well as the Apple Java 6 runtime, but no Oracle jdk7+ installed.

  • How to run JRE from an external USB disk

    Hi
    I wanted to put up a tomcat servlet engine that could run from a USB harddisk without any previous installment on the host machine. The OS of the host machine would be windows 2000.
    My first question would be; is that possible ?
    I think that when i install JRE environment on some w2k machine som registry stuff is created. And my problem here would be, how to run the java without any registry updates and directly from the USB stick that i insert into the machine.
    And my second would be; what should i install of java on the USB to make this work?
    Grateful for any input on this, or any pointers.
    Best regards
    Abid

    You would need the whole JRE on the media, and I would also assume the the full SDK/JDK as many servlet containers use the SDK's java compiler if you're doing JSPs.
    You would then simply install your servlet container and your .war files. Now I believe that registry settings are not mandatory but one must ensure the PATH, JAVA_HOME, and CLASSPATH environment variables are set accordingly, thus a startup script (.bat/.cmd) would be necessary to create the OS environment, spawn the JRE and in turn invoke the servlet container.
    I've never done this with tomcat, but I've done very similar things with Jetty FYI.

  • How do run unix command in java

    hi
    All unix command working fine in our java program.
    but i want change user in linux by using java. it's not working.
    "su root" This command onely not working.
    anybody know help me
    This is my ID [email protected]
    This my code
    <% String s = null;
    try{
    Process p = Runtime.getRuntime().exec("su root");
    BufferedReader stdInput = new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError = new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    out.println("Here is the standard output of the command:\n");
    while ((s = stdInput.readLine()) != null)
    out.println(s);
    catch(Exception e) {}
    %>

    I don't have further info to add to your first post, but think your guess seems quite reasonable. I thought of starting a new thread on the same topic, but think this (question) fits in here, too.
    I have Java code (freeware, not opensoure), intended for Unix, which basically provides the graphical interface and relies on an I/O layer (C + shell scripts) to do most of the work. I have access to the C+shell scripts which are opensource. I ported it to Cygwin and want to use it under Windows (there is no Cygwin native Java VM).
    My problem now boils down to " how to run commands under Unix and what differences are there with Windows". What are the variants?
    I have to guess what the program is doing when I get an IOException at some point. E.g.: a call to shell script may be made in a different way as to a compiled exe in Unix?. I found a way to bypass path problems because forward slashes are also accepted and /cygdrive/c construct can be replace by c:/; shell scripts can be compiled into exes using shc and they work; if symbolic links are replaced by duplication of exe files, they work. What will happen in an instance whereby a process runs a shell script dynamically, through a pipe (the shell script is compiled in the Cygwin/win version and receives parameters) in a construct like:
    pipefp = epopen(cmdbuf,"w"); /* (cmbuf is "makehdr par1 par2 ... ") (makehdr was a shell script and is now compiled exe for Cygwin/Windows) */?.
    Thanks.
    LT

  • How To run jdk1.4.1 application in jdk1.1.6?

    Hi,
    we have developed product into jdk1.1.6 and it is used by many of our clients, now we r developing patches to the product using java2. How to run these packges using older version of java.
    we tried using runtime, but it is not working so plz if there is any possible way convey it to me on [email protected]
    Thanks and Have a nice Day.
    Anand Pimple

    Hi, did you use any classes or methods which are new since 1.1.6? If not, you can specify the JDK version you want to compile for when you call javac -target <yourVersion>. If you do use newer classes, you might be able to use them by incuding them in your classpath. If you use new methods in existing classes, my advice would be to go back and change your code.
    Cheers, HJK

Maybe you are looking for

  • How do I change an iCloud account on an iPad?

    My iPhone and iPad use 2 distinct iCloud accounts, as a by product of the mobile me exit. Now I want to sync these 2 devices, so they need to use the same iCloud account. When I start to change the iPad account, I receive a dire warning that all data

  • Can't open youtube on my i pod 5. what's going on?

    Why can't i open youtube on my i pod 5, can anybody help with this?

  • Powerbook 180c Display Screen Troubleshooting

    Hello, I'm trying to repair at least one, and maybe two of my old standby 180c laptops. I do have a CD showing the physical take-apart illustrations. I'm looking for help in troubleshooting the Interconnect, Inverter, Daughterboard and/or Cousin Boar

  • Lack of TCP keepalive parameter in Microsoft SQL Server ODBC Driver for Linux

    Hello, the problem in the aforementioned driver is the lack of TCP keepalive parameter that results in hanged threads because of closed connections on the SQL Server side, but not closed sockets on the client side. This could happen due to network-re

  • GT60 0ND - OverHeating (i think so)

    Ok so, i started play World of warcraft - wow - again like a month ago ca. I noticed that my fans were working more than usual, but didnt gave it a thought really. here a week ago or something my pc overheated and shut down. And then again the a coup