LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 05-21-2006, 08:23 AM   #1
chief_officer
Member
 
Registered: Mar 2006
Location: Istanbul, TR
Distribution: Red Hat, CentOS, Ubuntu
Posts: 181

Rep: Reputation: 30
Netbeans compile and run, but I can't do it from the console...


Friends,

I have just downloaded Netbeans IDE 5.0 from Sun's website and installed it on my SuSE 10.0 box. I'm trying to play with java, but in the first minute I had a problem. Here is my code in the netbeans:

Code:
package javaapplication1;

public class Main {
    
    /** Creates a new instance of Main */
    public Main() 
    {
        }
     
    public static void main(String[] args) 
        {
        System.out.println("Hello World");
        }
    
}
When I compile and run the projects within Netbeans, the output is as follows:

Code:
init:
deps-jar:
compile:
run:
Hello World
BUILD SUCCESSFUL (total time: 0 seconds)
In the dist directory, there is a README.TXT file that tells me to type the following to run the program from the console:

Code:
java -jar "JavaApplication1.jar"
I get the following error messages:

Code:
Exception in thread "main" java.lang.UnsupportedClassVersionError: javaapplication1/Main (Unsupported major.minor version 49.0)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
How can I run my applications from the console as Netbeans does? I don't understand why netbeans compile easily and my command doesn't?

Thanks for your assistance as always.

Regards.
 
Old 05-21-2006, 09:43 AM   #2
dom83
LQ Newbie
 
Registered: Jan 2006
Posts: 20

Rep: Reputation: 1
As far as I know this Exception is thrown when you are trying to run Byte Code wich was compiled for a newer VM.

Maybe you have an older JRE Version on your computer?

So you can do either:
- Remove all JRE packages (the development package JDK includes the java VM, so there is no need to have both JRE and JDK)
- Or you build your Byte Code for older Java versions. I don't know where you can tell Netbeans to do so (probably in the "project menu"?). But if you want to compile your source with javac you can use the option "-target".


Good luck,
Dominik
 
Old 05-22-2006, 01:41 AM   #3
chief_officer
Member
 
Registered: Mar 2006
Location: Istanbul, TR
Distribution: Red Hat, CentOS, Ubuntu
Posts: 181

Original Poster
Rep: Reputation: 30
I have checked my JRE installations and it is 1_5_0. In my notebook JRE is not installed and the error messages are the same.
 
  


Reply



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
Installed netbeans but won't run. zwyrbla Linux - Software 4 04-13-2006 09:42 AM
LXer: Sun Microsystems Introduces NetBeans Profiler Milestone 11 for Optimized Java Application Run-Time Monitoring LXer Syndicated Linux News 0 12-23-2005 05:31 PM
video resolution in console after compile Wolfy Slackware 5 01-16-2005 01:58 AM
How to Run Win32 Console App in linux Console Lokie Linux - Software 2 08-12-2004 10:00 PM
No Framebuffer Console After 2.6.7 Compile AFI_Flame Linux - General 1 07-01-2004 03:49 AM

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

All times are GMT -5. The time now is 08:31 AM.

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