Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8440879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:25:13+00:00 2026-06-10T08:25:13+00:00

Im getting a strange error when im compiling my code on a server and

  • 0

Im getting a strange error when im compiling my code on a server and downloading it and trying to run it on my computer.

Im basically compiling some java files on an EC2 instance, then loading them into a storage for later use.

When i download the files onto my computer and try to run them i am getting the following errors:

Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value  
     4022320623 in class file HelloWorldPackage/HelloWorldClass
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:787)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:447)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)

I am compiling the files using the following method:

public void compileProject()
{


    String command = "javac ";
    for(String s: this.getPackages())
    {
        File[] files = new File("/home/benuni/CompileFiles/" + project + "/src/" + s).listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(".java");
            }
        });

        for(File f: files)
        {
            command = command + f.getAbsolutePath() + " ";
        }
    }

    try {
        System.out.println("command: '"+ command +"'");
        Process pro = Runtime.getRuntime().exec(command);
         printLines(" stderr:", pro.getErrorStream());

        pro.waitFor();

        this.moveClassFiles();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

and am uploading the files with this method:

public void uploadBin()
{
    for(String s: this.getPackages())
    {
        File[] filesInPackage = new File("/home/benuni/CompileFiles/"+this.project+"/bin/"+s).listFiles();

        for(File f: filesInPackage)
        {
            String key = this.project+"/"+this.version+"/bin/"+s+"/"+f.getName();
            s3.putObject("devcloud",key,f);

        }

    }

}

does anyone know what i am doing wrong?
The class files are runnable when i compile them on the computer, but when i upload them to the cloud and download them im getting the error?

Thanks,

Ben

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:25:15+00:00Added an answer on June 10, 2026 at 8:25 am

    Okay i figured it out with thanks to @Asaph mentioning the downloading going wrong..

    Basically the downloading was fine, it was the way i was writing the file.

    When im downloading projects, im downloading the source and binaries, but i was writing both files as if they were the same.

    So changed the code to check the file type and then use the appropriate writer when necessary. If by some miracle someone has the same issue or is doing something similar here is the code:

    (Note this was just written 5 second ago to fix the problem and is very poorly written, im about to refactor it myself, but i cant do everything for you)

    public void download(String project, String version, String location)
    {
        for(S3ObjectSummary s: getObjectList())
        {
            String[] data = s.getKey().split("/");
            if(data[0].equals(project) && data[1].equals(version))
            {
                S3Object object = s3.getObject(s3BucketName,s.getKey());
                InputStream input = object.getObjectContent();
    
                BufferedReader reader = new BufferedReader(new InputStreamReader(input));
    
                File file = new File(location +"/"+ data[0] + "/" + data[2] + "/" + data[3] + "/" + data[4]);
                if(!file.exists())
                {
                      try {
                          file.getParentFile().mkdirs();
                            file.createNewFile();
                    } catch (IOException e) {
    
                        e.printStackTrace();
                    }
                }
                try 
                {
                    if(data[4].endsWith(".java"))
                    {
                    Writer writer = new OutputStreamWriter(new FileOutputStream(file));
                    while (true) {          
                         String line = reader.readLine();           
                         if (line == null)
                              break;            
    
                         writer.write(line + "\n");
                    }
    
                    writer.close();
                    }
                    else if(data[4].endsWith(".class"))
                    {
                        System.out.println("Writing Classes");
                        byte[] buffer = new byte[8 * 1024];
    
                        try {
                              OutputStream output = new FileOutputStream(file.getAbsolutePath());
                              try {
                                int bytesRead;
                                while ((bytesRead = input.read(buffer)) != -1) {
                                  output.write(buffer, 0, bytesRead);
                                }
                              } finally {
                                output.close();
                              }
                            } finally {
                              input.close();
                            }
                    }
    
                } catch (FileNotFoundException e) {
    
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    
    
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting strange error when trying to read HTTP request in Netty: java.lang.NullPointerException at
I'm trying to run a rake task locally and I'm getting a strange error.
I am writing some code and I am getting a strange error: my for
Getting a strange error when trying to output some data as a response to
I'm getting a strange error from the Python interpreter when I run this code:
Getting a strange error when trying to insert data into an Access database using
I'm getting this strange error message when trying to clone or pull from git.
Trying to install pear package and keep getting this strange error. Can you shed
I'm getting a strange error that only occurs on the live server. My Django
I'm getting a strange error when I run the following function: TypeIDs=c(18283,18284,17119,17121,17123,17125,17127,17129,17131,17133,18367,18369,18371,18373,18375,18377,18379) featsave<-function(featfile,TypeIDs=TypeIDs) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.