简体   繁体   中英

Unable to execute .java file through Davik VM

I am following this link I have first executed this command successfully.

javac <path + filename>.java 

Then after when I am trying to execute following command I facing an error " class name does not match path ".

dx --dex --output=<path + filename>.dex <path + filename>.class

I have same name for .class and .java but I think I have to write explicit path of .class file name. So what to do now. There is some minor mistake that I am doing but not able to find.

Your command seems to be wrong:

dx --dex --output=.dex .class

Have you tried this?

dx --dex --output=YourClass.dex YourClass.class

dx is picky about the paths that you give it - the relative path of the class file relative to your working directory has to match the package of the class.

For example, if your command is

dx --dex --output=classes.dex out/com/example/HelloWorld.class

Then dx assumes that the package name of HelloWorld should be out.com.example, and complains if it isn't.

However, there is a trick - you can add a /./ path component in the path you give dx, to specify where the "root" is, with respect to the java package. If the package in the previous example is actually com.example, then you can do:

dx --dex --output=classes.dex out/./com/example/HelloWorld.class

Another option is to use the --no-strict option, which disables dx's path checks.

To avoid magic number problem ,First check your jdk version ,it seems there is a problem with jdk 1.7* . i reverted to jdk 1.6 .

Instead of using dx --dex --output=<path + filename>.dex <path + filename>.class we can do one thing put one or all your .classes files in one folder say classFolder now issue following command :

dx --dex --output=YourClass.dex  absolutePath/classFolder 

dx command will pick one or all class files in that folder .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM