Running helloword.java on linux

when i run the program i got the following error,
Exception in thread "main" java.lang.ClassFormatError: hello (unrecognized class file version)
at java.lang.VMClassLoader.defineClass(libgcj.so.8rh)
at java.lang.ClassLoader.defineClass(libgcj.so.8rh)
at java.security.SecureClassLoader.defineClass(libgcj.so.8rh)
at java.net.URLClassLoader.findClass(libgcj.so.8rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.8rh)
at java.lang.ClassLoader.loadClass(libgcj.so.8rh)
at java.lang.ClassLoader.loadClass(libgcj.so.8rh)
at gnu.java.lang.MainThread.run(libgcj.so.8rh)
now when i saw the version of java and javac they were both different javac 1.6.0,java having version "1.5.0"so tried to make them same ,came with this solution command:sudo update-alternatives --config java,but it shows only one selection  /usr/lib/jvm/jre-1.5.0-gcj/bin/java,not for java 1.6,can any one suggest any solution                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

What do these commands yield?
java -version
which javaSome Linux distros come with a built-in Java version, maybe lurking on the PATH before your one.
This awakes suspicion:
gnu.gcj.runtime.

Similar Messages

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

  • Pls help (running java on linux)

    Hello freinds,,
    I am in deep need..can anyone pls help me...
    I want to run my java programs on linux server.. Below are the steps I went thru to install jdk
    *** Download and copy j2sdk-1_3_1_10-linux-i586.rpm.bin to /usr/local/src.
    % su -
    # cd /usr/local/src
    # chmod +x j2sdk-1_3_1_10-linux-i586.rpm.bin
    # ./j2sdk-1_3_1_10-linux-i586.rpm.bin
    # rpm -ivh j2sdk-1_3_1_10-linux-i586.rpm
    Now test Java:
    # /usr/java/jdk1.3.1_10/bin/java -version
    Set the PATH environent variable.
    PATH="$PATH:/usr/java/jdk1.3.1_10/bin:."
    export PATH
    I went thru all above commands uninterruptedly.. Then I copied the folder containing programs in jdk1.3.1_10/bin folder
    Now when I am trying to complile or run an existing class it's gving following error message :
    java: command not found
    OR
    javac: command not found
    Can any one pls tell me where I am going wrong???
    Thanks in advance..

    From your query i understand you've installed java at "/usr/java/jdk1.3.1_10" location on your Linux box. I've a couple of queries -
    when u try to run "/usr/java/jdk1.3.1_10/bin/java -version" what do u see. Do u see the Java version information displayed on your screen ?
    and when you try export -ing the PATH variable with the following location added "/usr/java/jdk1.3.1_10/bin" and in the same shell type "which java" what do you see ? You should be seeing "/usr/java/jdk1.3.1_10/bin/java"
    If the above works then make changes to your profile file in order to ensure changes are saved for subsequent sessions.

  • Running Java on Linux

    Hello everyone,
    I am familiar with programming in Java on the Windows environment.
    However, I have recently installed Mandrake 10 on my desktop, and downloaded Sun's J2SDK 1.4.2_05 for Linux GTK2 systems.
    I have setup the environment variables for JAVA_HOME and CLASSPATH, and everything seems to be in order (I manage to call java and javac from the command line). The problem is that, whenever I try to run a java program, I get the following message:
    "Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object"
    How may I solve this?
    Thanks in advance for the help

    What did you set CLASSPATH to? Until you understand how Java's "package" construct works and how classes are found it's best not to set it, it often causes more problems than it solves.
    It sounds like you have got a very old version of java installed and it is getting used instead of your newly installed 1.4.2. I know that some Redhat distributions have this problem but I'm not sure about Mandrake 10. What is the output of "java -version" ?

  • Making a java program run in Windows and Linux via web applets

    Hello, this is my first post at java.sun.com
    I made an application in Linux, using Jbuilder Fundation 2005. I used the JDBC MySQL connector for Linux, and I used Mandriva as a distro. What I did is a program that allows me to connect remotely to my server, in order to update the news.
    However I want to create an applet, in which you could click a button, and the main frame of the program will load. I have no idea how to do this, since this program runs great on my linux machine, and from what I know it uses the MySQL JDBC jar that's installed on my machine, and a lot of classes from the Jbuilder program directory.
    How could I upload this program to a webpage (with the applet idea that I mentioned earlier) so that both Linux and (especially) Windows clients could use it?
    It will also be nice to know how to create a .jar file that has all of the required classes in it, I know that Jbuilder enterprise does this, but I don't have that version or plan buying it.
    Thanks in advance

    Put the jre folder from your JDK install in your app folder.ok, but in this way he doesn't have to download jre
    but I have to add it to the app folder so that an
    application large just some kilobytes would become
    some megas bigger... unless I have misunderstood what
    you're suggesting me of course.Yeah, that's the downside. However, 17 MB isn't very large by todays standards.
    jre\javaw -cp <your classpath> <your main class><your classpath> is the class i need to be run's path
    or my classpath?
    jre\javaw has to be written like this or preceeded by
    the path of jre directory?As long as you point 'start in' to the correct directory, I don't believe you have to worry about that. That path you have there isn't quite right (neither was mine) but I think you've got that under control.
    You can give anm explicit path, then you can have different users with different start-in values and store their properties there automatically.

  • Running a java service on linux (Redhat)

    I can create a basic script to run my java service, I can stop, and restart it from the command line when logged in. I have installed the script as a service. However, when I reboot, the service will not start. I have set it to be the very last thing to start on boot-up. I'm thinking it may have something to do with the fact that when I run a java program, it does not bring me back to the command line, it just 'hangs' until it is completed, and this particular java program will obviously hang indefinitely as it is a service.
    Any help would be GREATLY appreciated.
    Thanks,
    PAUL.

    Why not start it in the background? (a trailing ampersand)
    kind regards,
    Jos

  • Keyboard Problem while running Swing App on LINUX

    Hi All,
    We have a Swing based Application running on Windows Platform. We need to run the Application on LINUX. The Application does not have any problem and runs without problems for a few minutes but after that the keyboard stops to respond inside the application. Keyboard runs fine outside the application but no key events are recognized inside the application. Mouse is working fine even after the keyboard stops responding.
    Key Points:
    �     The keyboard is a PS/2 keyboard.
    �     Read Hat Fedora 5.0 is being used.
    �     The problems occur on both KDE and GNONE.
    �     The Java Version is jdk1.5.0_09
    The application is data entry application using EJB at server side. The client UI has lot of JTables and Desktop Panes/ Internal Frames. User use ctrl+tab, ctrl+shift+tab, tab, shift+tab, and other hot keys to navigate between Components. Listeners on keyboard Focus Owner are also used. We are unable to diagnose the problem because of the undeterminable nature of the problem. The problem occurs at anytime and does not occur on any special key/ combinations press.
    Thanks and Regards,
    Nishant Saini
    http://www.simplyjava.com

    I've just installed the JDK 1.4 on my debian box. I
    can compile and run a basic Hello World app using
    System.println, but when I try to run a simple swing
    app, I get an error like:
    Exception in thread "main"
    java.lang.NoClassDefFoundError
    at java.lang.Class.forName0(Native Method)
    at java.lang.... etc, etc.
    It goes on with about 30 different classes. It
    compiles fine, with no errors, but when it comes time
    to run, that's what I get. This is what I have in my
    .bash_profile as far as environment variables go:
    export JAVA_HOME="/usr/local/j2sdk1.4.1_01"
    export PATH="$JAVA_HOME/BIN:$PATH"
    export
    CLASSPATH="$JAVA_HOME/jre/lib/:$JAVA_HOME/lib:."The code works fine in Windows, so unless there's
    something platform-specific, I don't think there's a
    problem there. I've checked to make sure I'm not
    running kaffe by accident and I'm definitely running
    the right java and javac. I'm out of ideas. Any
    suggestions would be greatly appreciated.
    -dudley
    I may just be crazy, but your PATH looks a little screwy to me. I was under the impression that the standard java installation has its executables in the 'bin' directory, not the 'BIN' directory. Unless Debian has fallen to the evil empire, then I'm fairly sure file names are case-sensitive. I don't know if that will fix your problem though. Do you compile from the command line, or do you use an IDE???

  • Getting GTK error while running javaFX application on linux

    I developed an JavaFX application that works fine on Windows. So, I tried to run this same application on Linux (ubuntu x86) and it is not working. I setup all the environment with following this article : http://docs.oracle.com/javafx/2.0/release_notes_linux/jfxpub-release_notes_linux.htm. The Sample JavaFX applications available at http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html work great on Linux. But when I run my application, I got this error:
    java -jar prototipoGui.jar
    Exception in thread "main" java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._invokeLater(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.gtk.GtkApplication._invokeLater(Native Method)
    at com.sun.glass.ui.Application.invokeLater(Application.java:336)
    at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:617)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:138)
    at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:171)
    at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:264)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:417)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    ... 1 more

    I get the same message, when running my application in stand alone.
    May be there is a problem when running in aa KDE environment.
    But I developed my app in Eclipse under KDE4. If the app is started by IDE it runs.

  • Is it possible to run a java program without using the command prompt?

    Hi,
    I was wondering whether it is possible to run a Java program (not an applet) without using a command line in the command prompt?
    Basically I want to run a program that will be continually running in the background and hence I don't want to have a command prompt screen loaded up as well - I just want the program to be running in the task bar.
    I know how to run the program in the task bar - but I still need to launch the program from the command prompt - is there anyway I can get a program running without having to start it from the command prompt?
    Cheers

    Or create a desktop shortcut (in Windows) or an application launcher ( in Linux GUI).

  • Gentoo doesn't run a Java (Flash) application but Ubuntu yes

    Hello everybody.
    I can't find a solution to a Java-Flash-Gentoo related problem.
    I would like to run a Java program, using an [external library|http://djproject.sourceforge.net/ns/] , to realize a Java FlashPlayer. This is the code of the player:
    package testplayer;
    import chrriis.dj.nativeswing.swtimpl.NativeInterface;
    import chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer;
    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class Main implements Runnable {
        public static void main(String[] args) {
            NativeInterface.open();
            EventQueue.invokeLater(new Main());
            NativeInterface.runEventPump();
        public void run() {
            JFlashPlayer player = new JFlashPlayer();
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(player);
            JFrame window = new JFrame("Test");
            window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            window.add(panel);
            window.setSize(400, 400);
            window.setVisible(true);
            player.load("http://www.youtube.com/v/XyX-KJwUohw");
    }A window should be opened and the youtube video should play as well. Here's what I get on Gentoo Linux.
    [http://i.imgur.com/XyYdk.png]
    It doesn't find the flash plugin actually, even though it is installed and properly working.
    My Gentoo is x86_64 architecture and if I try to run the same application on Ubuntu (x86_64), it works like a charm.
    At the moment my www-plugins/adobe-flash USE flags are the following: 64bit -32bit.
    Why this piece of code runs on Ubuntu and on Gentoo not????
    Could it be something related to some environment variable?
    Thanks a lot!

    I asked to the mantainers yet actually, but they didn't solve me the problem at the moment.
    Perhaps some of you could have an idea of what I am missing on Gentoo.
    What I can tell you, is that I tried to run that application on a fresh Debian installation and I've got the same problem.
    So this happens because of something that is missing. But what?? :(

  • Java Servlet/Linux issues

    Hi-
    I use an applet that works fine on Windows but fails on Linux. It stops
    on the 'Loading Applet' screen. I've tested it in Mozilla, Netscape and
    KConqueror, all with the same result. I'm guessing it has something to
    do with the applet making an external socket connection. Strange thing
    is I have set the logging to level 5 and see no exceptions.
    Below are the Java log traces between Windows and Linux.
    Any ideas! I have noticed that many people are having this problem on
    Linux without any resolution.
    Dave
    From Windows:
    Referencing classloader: sun.plugin.ClassLoaderInfo@1dba45, refcount=1
    Added trace listener: sun.plugin.AppletViewer
    Added progress listener: sun.plugin.AppletViewer
    Loading applet...
    Initializing applet...
    Starting applet...
    Connecting http://imgproc3.weathertap.com:443/radarlab/radarlab.jar with
    no proxy
    Connecting http://imgproc3.weathertap.com:443/radarlab/radarlab.jar with
    cookie "WxTAP_Session=Confirmed"
    java.io.IOException: Caching not supported for
    http://imgproc3.weathertap.com:443/radarlab/radarlab.jar
    at sun.plugin.cache.CachedJarLoader.download(CachedJarLoader.java:323)
    at sun.plugin.cache.CachedJarLoader.load(CachedJarLoader.java:131)
    at sun.plugin.cache.JarCache.get(JarCache.java:177)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect
    (CachedJarURLConnection.java1)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile
    (CachedJarURLConnection.java:56)
    at sun.misc.URLClassPath$JarLoader.getJarFile(URLClassPath.java:498)
    at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:459)
    at sun.misc.URLClassPath$2.run(URLClassPath.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:244)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:221)
    at sun.misc.URLClassPath.getResource(URLClassPath.java:134)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:132)
    at sun.plugin.security.PluginClassLoader.findClass
    (PluginClassLoader.java:189)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:112)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:473)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1621)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
    at sun.applet.AppletPanel.run(AppletPanel.java:290)
    at java.lang.Thread.run(Thread.java:536)
    WARNING: Unable to cache
    http://imgproc3.weathertap.com:443/radarlab/radarlab.jar
    Connecting http://imgproc3.weathertap.com:443/radarlab/radarlab.jar with
    no proxy
    Connecting http://imgproc3.weathertap.com:443/radarlab/radarlab.jar with
    cookie "WxTAP_Session=Confirmed"

    Hi
    I have big problem
    When i change the jdk at 1.3.1 from 1.4.0
    my applet work some time
    Is someone is able to say why
    Thanks
    The error was :
    java.io.IOException: Caching not supported for http://192.168.205.53/classes/SAComm.jar
    at sun.plugin.cache.CachedJarLoader.download(Unknown Source)
    at sun.plugin.cache.CachedJarLoader.load(Unknown Source)
    at sun.plugin.cache.JarCache.get(Unknown Source)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.getJarFile(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.<init>(Unknown Source)
    at sun.misc.URLClassPath$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath.getLoader(Unknown Source)
    at sun.misc.URLClassPath.getLoader(Unknown Source)
    at sun.misc.URLClassPath.getResource(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 sun.applet.AppletClassLoader.findClass(Unknown Source)
    at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    bartos

  • Running/Compiling *.java file in Oracle Sql Developer

    I want to compile/run java 5.0 files in Oracle sql developer1.1.2.25 on Fedora 5 platform.
    I have added javac as an enternal tool to compile java programs. Tools-->External Tools-->New
    I have also added java: /usr/java/jre1.5.0_10/bin/java as an external tool to run the complied programs
    I am able to compile the java programs, but i am not able to run them.
    I am providing ${file.name.no.ext} as an argument to java.
    Java-Log Output is:
    /usr/java/jre1.5.0_10/bin/java Writer2
    Exception in thread "main" java.lang.NoClassDefFoundError: Writer2
    However, if i run the same program in Linux terminal, i get the correct output:
    [root@localhost java]# which java
    /usr/java/jre1.5.0_10/bin/java
    [root@localhost java]# /usr/java/jre1.5.0_10/bin/java Writer2
    12
    howdy
    folks
    How can i make Oracle Sql Developer run the java program?

    I will echo the use jdev comment..
    Regardless, you may want to check the execute in directory.. or add a -cp parameter.
    Eric

  • How to run standalone java file from weblogic server on Solaris

    Hi,
    We have a requirement to run a java file at a scheduled time in a day using cron scheduler on our linux server.
    We need to fetch data from the database & perform some business logic in this standalone JAVA file.
    Our application has an EAR which is deployed on Weblogic 10.3 server & in our application, we are utilizing the datasource created in that domain.
    Now, we have created a standealone Java file & used exisitng datasource (without Hibernate) of the domain with the help of below forums,
    Use DataSource of weblogic in a standalone Java file
    able to achieve the same.
    I've bundled this JAVA in application WAR & depoyed on the same domain where datasource is created.
    Now, how can I execute this file from anywhere on the server using weblogic classpath.
    Please help on the same in implementation.
    Thanks,
    Uttam

    If the Java application must be stand-alone you must not deploy it on WebLogic, then WebLogic will manage its lifecycle.
    In this case you can use the CommonJ API and use the timermanager if it must run on a certain time. More information
    of how to do this can be found here: http://middlewaremagic.com/weblogic/?p=5569
    If you keep the Java application stand-only and want to use a cron job you can follow the example presented here: http://middlewaremagic.com/weblogic/?p=7065
    Note that the example runs a WLST script, but you can follow the same steps to run your Java application.

  • How do run the jni in linux enviroment??

    I run the HelloWorld sample in linux
    but I stock in load the share library!
    When I type this command as following:
    cc -G -I/usr/local/java/include -I/usr/local/java/include/linux \
    HelloWorldImp.c -o libhello.so
    there are error message like this :
    unrecognized option '-G'
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o:In function '_start':
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18):
    undefined reference to 'main'
    can you help me solve the problem?

    gcc -I/usr/lib/java-1.3/include -I/usr/lib/java-1.3/include/linux \
         -fPIC -g -c -Wall HelloWorldImp.c
    gcc -shared -Wl,-soname,libhello.so -o libhello.so HelloWorldImp.o
    when you call the library in java
    System.loadLibrary("hello");

  • Running .jar files in linux on double click

    Hi,
    i needed a solution to run the jar files on double click in linux system.Necessity is mainly because when i run the jar file by java -jar myapp.jar in terminal it works fine .Iam running my app continuosly in system tray(a server kind).But if i close the terminal my app exits.
    How to resolve this ?

    I am taking a SWAG.....it sounds like your problem is how to run a java app without a terminal window. So as I recall, there is some way in Linux to enter a command and have it execute in a new process. I don't recall the syntax but maybe putting a '&' character in the command line? Anyway, you should be able to use the method and use "javaw" instead of "java" to launch your app. You should be able to do this in a batch file too. Something like, javaw -jar yourjar.jar &

Maybe you are looking for