Coder Social home page Coder Social logo

Comments (6)

GuzioMG avatar GuzioMG commented on July 23, 2024

I have no clue, what's causing the lack of -jshell, but "Could not find or load main class" is a problem with your application, not Java*. It means, that the file you're trying to run does not have a main() method. The only solution I can see here is:

  • Java does not have access to your file (for some reason)
  • Application is broken (probably)
  • You're running a .jar file without -jar parameter (make sure it's the last one)

*However, if you're still not sure, you can always try running a different app, that you're sure, it works. Minecraft server is running fine (although it melts your phone). I checked.

from termux-java.

kparsh19 avatar kparsh19 commented on July 23, 2024

Well, I will give answer to your points in the same way

  1. I think this is the main reason behind this. I have seen some videos about this same issue coming in windows, they have solved it by making a new environment variable
  2. It is impossible (I hope) because it's termux
  3. There is nothing related to .jar/-jar because it's one of the simplest program I have written using an editor with .java extension and I just want to compile/run it on termux
    May be it is due to absence of -jshell or may be there's something wrong in this package. While compiling the program using javac (.java) it compiles fine and also I had seen that .class file is also generated but this error occurs when I try to run it using java command. I have checked the path.

from termux-java.

GuzioMG avatar GuzioMG commented on July 23, 2024

Well... It's probably exactly what you just did and I'm asking this question for no reason, but: Are you sure that (since you're running a .class file) you're using java Program not java Program.class? I just checked and java Program.class returns Error: Could not find or load main class Program.class, while the other one works. Also, you must be in the same folder.

from termux-java.

kparsh19 avatar kparsh19 commented on July 23, 2024

Yeah, I have used java_program and not java_program.class with java command because I know that latter will create this error. But the unfortunate is the same error with java java_program command

from termux-java.

GuzioMG avatar GuzioMG commented on July 23, 2024

:-/ Well, I have no clue then.

But could you please try running a .jar file, just to make sure it's really not working? Maybe there's an issue with .class files on your phone. For... some reason 🤔?

from termux-java.

johnmalib avatar johnmalib commented on July 23, 2024

According to the error message ("Could not find or load main class"), there are two categories of problems:

  • The Main class could not be found
  • The Main class could not be loaded

The Main class could not be found when there is a typo or wrong syntax in the fully qualified class name or it does not exist in the provided classpath.

The Main class could not be loaded when the class cannot be initiated. Typically the main class extends another class and that class does not exist in the provided classpath.

For example:

public class YourMain extends org.apache.camel.spring.Main

If camel-spring is not included, this error will be reported.

Other reasons to occur this error is :

  • File Extension
  • Wrong package
  • Invalid Classpath
  • Wrong Class Name

from termux-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.