Java program runs differently on Windows and Linux

Hi!
I would like to run a java application (which is written and run on windows platform) on linux platform. I don't know wether it is possible or not, but I tired on the following way:
I have made a small java application. It worked correctly on windows (I developed it on windows). I copied first only the class file (Start.class) to the linux machine (which has exactly the same JDK as windows machine). When I type the command:
java Startit gives me the folloving error:
Exception in thread "main" java.lang.ClassFormatError: Start (unrecognized class file version)
   at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)
   at java.lang.ClassLoader.defineClass(libgcj.so.7rh)
   at java.security.SecureClassLoader.defineClass(libgcj.so.7rh)
   at java.net.URLClassLoader.findClass(libgcj.so.7rh)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)After that I was trying to compile the source file on linux with the command:
javac Start.javabut the compiler gave me an error in the source file.
Is there any way to run the formerly written java application (on windows) on linux machine?
Thanks

When I type the command java-version I get the following:
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-46)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.The JDK on linux and windows is the latest (I was download it today).
How can I upgrade the jdk/jre on linux?
Here is the compiler error:
[root@Linux-oracle app]# javac DataMining.java
1. ERROR in DataMining.java (at line 77)
        ArrayList<String> temp = new ArrayList<String>();
        ^^^^^^^^^
The type ArrayList is not generic; it cannot be parameterized with arguments <String>
2. ERROR in DataMining.java (at line 77)
        ArrayList<String> temp = new ArrayList<String>();
                  ^^^^^^
Syntax error, parameterized types are only available if source level is 5.0
3. ERROR in DataMining.java (at line 77)
        ArrayList<String> temp = new ArrayList<String>();
                                     ^^^^^^^^^
The type ArrayList is not generic; it cannot be parameterized with arguments <String>
4. ERROR in DataMining.java (at line 77)
        ArrayList<String> temp = new ArrayList<String>();
                                               ^^^^^^
Syntax error, parameterized types are only available if source level is 5.0
5. WARNING in DataMining.java (at line 240)
        String youtube[][] = new String[20][5];
               ^^^^^^^
The local variable youtube is never read
6. WARNING in DataMining.java (at line 267)
        int e;
            ^
The local variable e is never read
7. ERROR in DataMining.java (at line 329)
        for(int i=1;i<Video+1;i++)
                      ^^^^^^^
The operator + is undefined for the argument type(s) Integer, int
7 problems (5 errors, 2 warnings)

Similar Messages

  • String.getBytes (java) o/p different in Windows and Unix

    Hi,
    I was trying out the following code, which gives me a byte array from a
    String object.
    byte[] bytArr = null;
    bytArr = <String object>.getBytes("UnicodeBigUnmarked");
    System.out.println(bytArr.toString());
    The output is different in Windows and in Unix. The assumed that the reason could be because Intel architecture is based on little_endian so the difference in output. I changed the code to the following
    bytArr = <String object>.getBytes("ISO8859_1");
    and then ran the class file by using "java -Dfile.encoding=ISO8859_1" so that the toString can also take the character encoding of ISO8859_1 rather than using the platform dependent one. Still the result is different in Windows and Unix.
    What could be the reason for this? How can I correct this ? Any help in this regard is welcome.
    cheers
    kk

    Hi Sabre150,
    Thanks for the suggestion, it worked. Both the o/p shows the same if I use System.out.println(Arrays.toString(bytArr));
    I am assigning full points to you. Thanks a ton for the help.
    To end with I have one more question, the method Arrays.toString is introduced from jdk1.5, so if I want to use jdk 1.4 what should I use instead of Arrays.toString ?
    It would be great if I can get this answer.
    cheers
    kk

  • Flash behaves differently in windows and linux ?

    There are some sites that flash doen't display too well (firefox/opera) in linux, but seems to work fine in windows. Is there a difference in the plugin for each OS?
    try this:
    http://www.asus.com/index.aspx
    Wait for the page to finish loading, and then hover your mouse over the "products" link at the top of the page.. the drop down menu is now masked by the "asus webcam notebook ad". This doesn't happen in windows.. I've tried both arch package and the default flash installer, but get the same results.
    Note: The drop down menu is visible if you use the flashblock extension and disable the ad.
    Thanks..

    yep, for some reason the linux flash plugin doesn't let the browser draw elements over the animations, which is especially annoying on websites like the one you mentioned where dropdown menus are used over a silly useless flash banner.
    there are a LOT of things wrong with the flash plugin. macromedia hasn't really addressed them in a long long time
    EDIT: which is why i wish the best of luck to the gplflash plugin developers.

  • Different behaviour on windows and linux

    On a text field , I have attached a number converter, just to make sure that user enters the number else gets an error message.
    Things looks fine but it behaves differently on windows and linux os.
    When I am running this application on windows if user enters
    123456.46, it is stored as it is i.e 123456.46 in MySQL db.
    However, if run this on linux and if user enters 123456.46 then it is stored in MySQL db as 123456.460000000006402842700481414794921875
    I am not sure where the problem is. Can somebody guide me about it.
    Thanks.

    Not sure why the behaviour is different, but coded to remove the extra fractions.

  • Differences on Windows and Linux JVM about java.util.zip package

    Hello, there!
    I need some help if someone else has already face this problem.
    I have a Java server that process the bytes of a SWF File stored in the server and ouptut it to the user through a Servlet. The file was decompressed and re-compressed using the java.util.zip package (Deflater/Inflater).
    Everything works fine on Windows Server 2008 server. But now we need to migrate the server to Linux. The problem is that when I test the website now, the file seens to be corrupted.
    What really intrigues me is that everything runs normal on Windows Server configuration, when changed to Linux, the final file seens to be corrupeted... what could possible be the cause? Is there any difference between java.util.zip package on Window and Linux JVM?
    My Windows Server is:
    . Windows Server 2008 (6.0 - x86)
    . Apache 2.2.11
    . Tomcat 6.0.16.0
    . Java JDK 1.6.0_12-b04
    My CentOS Server is
    . CentOS 5.4 (2.6.18-164.15.1.el5 - i386)
    . Apache 2.2.3
    . Tomcat 6.0.16.0
    . Java JDK 1.6.0_12-b04
    Please, if someone could give me a lead, I would appreciate very much!
    Thank you all in advance,
    CaioToOn!

    ejp wrote:
    Thank you for the answer, but no. The path is correct.That's not what he meant. Zip file/directory entries are supposed to use / as the path separator. It is possible to use \ but such Zip files will only work under Windows. You may have erred here.Ohhh, I had really missunderstood what Ray said. But, I still think that this is not the problem, since the ZIP is a single SWF file generated by Flex SDK 3.4 and compressed in the ZLIB open standard (as in page 13, at [http://www.adobe.com/devnet/swf/pdf/swf_file_format_spec_v9.pdf|http://www.adobe.com/devnet/swf/pdf/swf_file_format_spec_v9.pdf] ). This is how Flash Compiler compress the files.
    jschell wrote:
    If the above suggestions do not solve the problem...Specify in detail with the exact steps used how you determined that it was corrupted.The reason why I believe the SWF is getting corrupted is that when it is loaded by Flash Player (in the client-side) the Player throws a VerifyError: Error # 1033. The [documentation says (see error 1033)|http://help.adobe.com/en_US/AS3LCR/Flash_10.0/runtimeErrors.html] that this error means that the SWF file is corrupted.
    As I said, what intrigues me is that this work perfectly in a Windows Server 2008 server. I just had setup a CentOS server and deployed the application. The client-remains unchanged, so why could the result change?
    raychen wrote:
    I would remove the side effect you are doing and send the file straight through, with decompress and compress, the servlet. It is more likely that you have a bug in your swf processor than the zip library.
    I had already tried it when first coding, in Windows Server 2008, it had not worked.
    Thank you all for the help.
    CaioToOn!

  • How to execute unix command from the Java program running on Windows

    Hello,
    I need to
    1. Execute a unix shell script from a Java program running on the Windows.
    2. I also need to capture the output of this shell script in my program.
    Please suggest me how to achieve this.
    Thanks in Advance.

    Hi...
    Something is missing here
    If you want to execute a shell script in windows that not posible unless you find or develop a unix shell script parser for windows.
    But if you are trying the execute a unix shell script on a remote unix computer from your java program running on a windows platform you can do that by logging on to the UNIX terminal which is running on port 23 I think.
    You can test this using telnet tool on windows
    just type on command prompt
    telnet <ip of the unix pc> <port number this case 23>
    you should get the unix terminal. If that works you can do the same through java or you can directly conect to port 23 of that pc using sockets that way your program will be platform independant

  • Compile and run java programs in different directroy

    Hi,
    I often encounter many problems when I run java programs in the different directories. Like
    javac -d dir_name a.java
    java -cp dir_name a
    Something wired often happens, such as, there is not a.java file in some directory, but javac -d dir_name a.java can still work or "java -cp dir_name a" often doesn't work. Moreover, file_name.jar is also a tough problem and solving compiling problems is often time-consuming.
    So I hope to read something about how to compile and run java programs in different directory properly.
    Could you pleae give me a detailed description for that or recommend a book or website?
    Thanks a lot.

    Can you post a small amount of code that does not work, including the directory structure, and the error messages? Some one here can likely explain the problem.

  • Vim and Eclim (Java): Run Java program in embedded terminal window

    Hello all,
    I'm trying to create a decent Vim setup for Java programming. I've installed Eclim, and it works alright. However, one annoyance I have is the way that Eclim runs Java programs. When run (via the :Java command in Vim), a Java program runs in a new shell instance pretty independent from Vim, and then when the program terminates (and Enter is pressed), the output is put into a new buffer at the bottom of the Vim window with the output.
    The problem with this is that I must press Enter to go back to Vim after the program terminates, and then the output buffer is automatically selected even though I most likely do not care to copy any of the output.
    So, this is what I would like to happen:
    - I run my Java program somehow (doesn't have to be with :Java)
    - A buffer containing the running program in a shell is put on the screen (if not already there)
    - The program terminates, and the focus did not change to the output buffer
    At the very least, I want the focus to not change to the output buffer after the program is done running.
    Any ways to at least somewhat accomplish what I'm trying to  get at?

    Trent wrote:
    Yeah? I had AP CS when they first introduced the GridWorld case study. I hope you get more out of the class than I did.
    I have never used Java except for that and my first CS class at university. I eventually realized that software (as a job) wasn't for me and took a route closer to EE. I still fight to avoid being called a programmer though
    I like the idea of programming for a job, not necessarily "software development", something computer science-y sound good to me.
    But anyway, to end on an on-topic note, I embedded gvim inside Eclipse as described here.

  • Execute Unix command from Java program running on windows

    Hello,
    I need to write a java program that fetches file count in a particular unix machine directory. But java program will be running on windows machine.
    The program should execute unix list command and fetch the output of that command.
    Can anyone help me on this?
    Thanks.

    Hi there,
    I had a similiar problem, though years ago. It was to have a java program execute any other. Lately, I've had to have a java program running on a unix machine execute a shell script. Entirely two different scenarios. I'm not sure what you will need for your app, but look into this:
    Java Native Interface for executing C/C++ code.
    C/C++ Code for launching the program you need to run.
    java.lang.Runtime(?).exec(....)
    With a combination of that stuff, you can make a launcher for any os that has Java running on it, and with Runtime, you can exec() pretty near any sort of unix shell or app command you'd like.
    Good luck.
    Tim

  • Process name representation in a LINUX machine for a JAVA program running..

    Hi,
    We are using an Intel machine loaded with Red Hat Linux 7.2 OS to run JAVA programs. We have a requirement to calculate the CPU and MEMORY usage for each JAVA program running. Unfortunately when a java program is run say "java ESR" and we run a ps -ef | grep -i java, it is shown as hkumar 2847 2799 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2874 2847 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2875 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2876 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2877 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2878 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2879 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2880 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2881 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2882 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2883 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2884 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    hkumar 2885 2874 0 19:15 pts/3 00:00:00 /usr/java/jdk1.3.1_03/bin/i386/n
    instead of the actual name of the program ie. ESR.
    Does anybody know why this happens? Is there a way out to ensure that "ps -ef | grep java" gives the actual name of the java program being RUN?
    Thanks in advance,
    Harish

    You have less chance to identify which programm that VM instance is running right now.
    But you could (as we do) keep track of your programs if you save the process-id when you start the program.
    We need this to shut down running java batch programs but you could find out the used system resources with this way as well...

  • Executing WINWORD from both Windows and linux using Java

    Dear All,
    I have a problem when trying to use Runtime class to execute a winword document. My code is as follows.
    Runtime r= Runtime.getRuntime();
    try{
    r.exec("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"WINWORD"+ " "+"file://C://welkom.doc");
    catch(Exception ex){
    System.out.println("Unable to open the doc file:"+ex);
    When I execute this swing application with the above, the program is unable to open the specific file. And it says "Problem with the short cut, unable to open the file". When I run the program without the file name, it opens a new doc file.
    Attn: what I want to do here is I need to open the winword file from both windows and linux. So I cannot use the relative path of the WINWORD.exe file.
    Can anyone help me?
    Thanks in advance.
    Regards,
    Bala

    If you take a look at the api, there's an exec(String[]) method. This is the one you should use when calling a command with multiple parameters.
    so something like...
    String[] cmd = new String[] {"rundll32", "url.dll,FileProtocolHandler", "WINWORD", "file://C://welkom.doc"}
    r.exec(cmd);

  • RMI-server works on Windows and Linux but not on Solaris

    I wrote an application which uses RMI. The server is successfully tested on Windows and Linux. However it doesn't work on Solaris.
    Naming.lookup works, I can find the server. But calling a method on my remote interface causes a ConnectionException:
    java.rmi.ConnectException: Connection refused to host: 192.168.1.123; nested exception is:
         java.net.ConnectException: Connection refused: connect
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
         at sun.rmi.server.UnicastRef.newCall(Unknown Source)
         at at.triton.javaengine.server.ServerImpl_Stub.connectToWindow(Unknown Source)
         at at.triton.javaengine.client.JavaEngineClient.connectToWindow(JavaEngineClient.java:288)
         at at.triton.javaengine.client.JavaEngineClient.main(JavaEngineClient.java:787)
    Caused by: java.net.ConnectException: Connection refused: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.SocksSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
         ... 7 moreNote that I have almost no experience with Solaris.
    Additional information about the common pitfalls which I have already checked:
    * rmiregistry finds the server classes (the exception was different without them)
    * the server is in the LAN and the desktop firewall of the client is double-checked to let the required ports through to any destination.

    java.rmi.ConnectException: Connection refused tohost: >192.168.1.123; nested exception is:
    java.net.ConnectException: Connection refused:
    : connect
    Clearly indicates what is happening inside there.Clearly indicates that you don't know what you are talking about.
    Any applications invoked with a security manager must
    be granted explicit permission to access local system
    resources apart from read access to the directory and
    its subdirectories where the program is invoked.Any application that gets a java.net.ConnectionException: Connection
    refused is getting it more or less directly from the TCP/IP stack. If the problem had anything to do with policies and permissions and SecurityManagers, it would have been an AccessControlException .
    if your client RMI doesnt include these lines then If your 'client RMI' does include these lines then I would like a definition of what exactly a 'client RMI' really is, because I've been using RMI for ten years and wrote a book about it and I certainly don't know.
    1)just include these lines
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new
    SecurityManager());In other words, if the application doesn't already have a security manager, in which case the contents of the policy file or the 'client RMI', or whatever you want to call it, are completely irrelevant, such that they couldn't possibly be having the problem you desrcribe, add a security manager so that we get into the land where you might possibly know what you're talking about?
    e a policy file
    grant {
    permission java.net.SocketPermission
    "192.168.1.123:1099", "accept,connect,resolve";
    };And this is completely unnecessary if there isn't a security manager, and completely unrelated to the OP's problem.

  • Java Program in Different Operation Systems

    Just one question? can I use a java program (.jar) compiled in windows, in my solaris only by copying the .jar , or do I need to compile it with the solaris SDK?
    Thanks in advance for your help and sorry for my ignorance.
    Javier

    Hi,
    It is not required to recompile bcoz the .jar file contains .class files which are independent of Operating system which will be taken care (interpreted) by JVM.
    Actually there is different JVM's for different operating systems(Windows 98,Unix,OS/2). No need to have differend java class file for different operating system. Pls, remember Java is platform independent language.
    Regards,
    S.Prabu

  • Dual booting in Windows and Linux, but only Linux has calendar, TB 31.0

    I'm dual booting using Linux Mint and Windows 7. I have TB 31.0 installed in each OS. TB in Linux has calendar capability; in Windows, there's nothing (by nothing, I mean no calendars - I can't see their properties, for instance, nor access them in any way).
    I should add that both Windows and Linux TB programs are sharing the same profile folder (located on a separate partition), hence, all the same add-ons, passwords, etc.
    The error console logs the following:
    Timestamp: 14/08/2014 6:41:33 PM
    Error: Components.classes[cid] is undefined
    Source File: resource://calendar/modules/calUtils.jsm -> file:///P:/PortableApps/ThunderbirdPortable/Data/profile/extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-js/calUtils.js
    Line: 17
    There are a variety of flow on errors, related to this.
    My apologies for posting this in this way; I had intended to submit this via the crashreporter, but I'm having trouble getting the program to crash with this error just now.

    A reply to my own question: it turns out that while sharing a profile works pretty well for most purposes, with Lightning it does not, as the extension has different Linux and Windows versions. The problem is solved quite simply: by not using the same profile for each version.
    Glad to see that no one wasted time on this one (except me, of course).

  • Problem with JOGL applet on Windows and Linux

    I made a simple test applet using JOGL involving a simple animation and a KeyListener. It put it on a web site, and it loads and runs correctly on my Mac, but it gives a blank box with a red x in it on Windows and Linux. Here is the code that I used to deploy the applet. I based it off the sample from https://jogl-demos.dev.java.net/applettest.html
    <applet code="TestApplet"
    width=300
    height=300
    archive="http://download.java.net/media/applet-launcher/applet-launcher.jar,
    http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
    http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
    http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl-demos.jar">
    <param name="codebase_lookup" value="false">
    <param name="subapplet.classname" value="TestApplet">
    <param name="subapplet.displayname" value="JOGL Applet">
    <param name="noddraw.check" value="true">
    <param name="progressbar" value="true">
    <param name="jnlpNumExtensions" value="1">
    <param name="jnlpExtension1"
    value="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp">
    </applet>
    Does anyone know what I'm doing wrong? Thanks for your help.

    never mind. i figured it out.

Maybe you are looking for

  • Downloaded game from Apple site - Photoshop crashes

    My son downloaded the game "Halo" from the Apple website last week and now Photoshop CS2 crashes while I am working in it. I have a 6 month old Imac G5 with Tiger (not the Intel version). Is Halo taking up memory? Would it be ram or hard disk space?

  • G5 xserve: How do I boot from a FireWire device ?

    Hi. I have a PowerPC G5 server WITHOUT a keyboard/display and have just installed Leopard 10.5.1. After setting up Leopard, I made a backup copy of the server HD onto a Lacie FireWire hard-drive device connected to the FireWire 400 port on the front-

  • How to change users short name in 10.7 Server version?  Command line possible?

    I just migrated from Snow Leo 10.6 Server to Lion 10.7 server.  All seems ok except for one user (me!).  It seems my short name is different.  It was Goerge Smith but now it is just George.   And All users can login and get mail etc, but not me. I tr

  • Best practice for conditional region display

    I feel like I'm missing something here... What's the easiest way to control display of a region only if the user has submitted that same page via a button? For example, I only want to display a search results region if the user has entered search cri

  • Flash + IE7 +User account = bad

    I've read a number of the threads and have tried the reset_mini/SubInACL along with uninstalling/reinstalling as user and as admin. Flash + Firefox =No Problem Flash + IE 7 in user account = Heartbreaking pain and dispair Flash + IE 7 in admin accoun