First, my issue is similar to those two :
JAVA gettext commons
error reading .po file in java
I want to use GNU Gettext utility for internationnalizing my app. I managed to get it working by creating a translations.properties file with the proper key-value pair but it wont get my translations_fr_CA.properties even if I explicitly set the locale to fr_CA or Locale.CANADA_FRENCH. This was my first issue.
Second and most important issue : I can't get rid of the .properties file which is crap as I can't use the nice gettext complete msgid . I managed to compile my .po file to a .class with msgfmt --java2 [...] but the ResourceBundle won't load without a .properties file.
Here is a zip of my current testing project : java_gettext_testing.zip
I included gnu.gettext.GettextResource in the zip to make it simpler. You can compile with javac test/*.java and run with java test.test
Thanks for any help!
I figured it out finally. I don't know why but I cant use .class files without putting them in a package. I reworked my structure and finally I can compile my .po file with
msgfmt --java2 -d . -r test.translations translations.po
which will compile the ./translations.po file to test/translations.class giving it the appropriate package information.
Now I can do this
ResourceBundle myRes = ResourceBundle.getBundle("test.translations"); // load my test/translations.class file
GettextResource.gettext(myRes, "message id to translate");
Still got to get the locale working but the essential is there for me right now.
Edit This question helped me to understand that msgfmt was compiling .po files into "real" java objects How to use ResourceBundle
Related
Here is the make file i am using to generate and JAVA module which i am importing in another module. While compiling it, the build breaks saying
error: 'out/target/common/obj/JAVA_LIBRARIES/android.hardware.automotive.vehicle#2.0-java_intermediates/classes.dex.toc', needed by 'out/target/common/obj/JAVA_LIBRARIES/vendor.harman.hardware.automotive.vehicle.fca_r1#1.0-java_intermediates/with-local/classes.dex', missing and no known rule to make it
Any suggestion on how to generate a .toc file in general?
Anything specific to be added in the make file?
Usually such toc file will be auto generated during fullbuild, but if it is missing when you build single module you can manually generate the classes.dex.toc with the following command:
dexdump2 classes.dex >> classes.dex.toc
If you want to know the details, please read the sourcecode of android build system: _transform_dex-to-toc
https://android.googlesource.com/platform/build/+/f972a4a980660d2347ace8fdc7c668403c0e9697/core/definitions.mk
I am writing some code to my phd project and I am using VIM as my code editor.
As I am coding in Java, I chose Syntastic to check and compile my code. So far so good.
My issue comes when I try to create a directory with all my .classes. I want to do this, because then I intend to create a .jar using this directory using a simple make file. So, this is my scenario:
source code:
C:\Users\LABIMD05\workspace\backhoe-nomvn2\src (all .java)
class files:
C:\Users\LABIMD05\workspace\backhoe-nomvn2\bin\classes (where I want to put all the .classes)
In this way, let's say I am coding br.ufrn.Project. When I use :SyntasticCheck, I want the br.ufrn.Project .class file to be generate at:
C:\Users\LABIMD05\workspace\backhoe-nomvn2\bin\classes\br\ufrn\Project.class
and not at:
C:\Users\LABIMD05\workspace\backhoe-nomvn2\src\br\ufrn\Project.class (the same of the .java)
Here goes the options that I am using at my _vimrc file
let g:syntastic_java_javac_classpath = 'C:\Users\LABIMD05\workspace\szz_lib\*;C:\Users\LABIMD05\workspace\backhoe-nomvn2\bin\classes'
let g:syntastic_java_javac_delete_output = 0
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'passive_filetypes': ['java']}
THE PROBLEM:
Everytime I compile br.ufrn.Project file, the .class file goes to the same directory of the .java file
I thought it would be because Syntastic would create the .class file in the current working directory. Then I used:
cd C:\Users\LABIMD05\workspace\backhoe-nomvn2\bin\classes
To see if Syntastic would create the .class in the desired place. But I had no success.
Would you guys have some clue where can I configure it? I just want to separate the .class files from .java files and then use a make file to create a jar with the binaries only. Simple thing.
Thank you for any help you can provide.
You can't configure Syntastic to compile the java files to a different location. However, you can make a command that uses SyntasticCheck and compiles the java files to a different directory.
Using the javac -d dir File.java command you can tell the java compiler where to generate .class files.
Using this you can make a vim command, I called it Javac but you can choose what to call it. It will call Syntastic check and generate the .class files to the other file.
function! Javac()
execute "w"
execute "SyntasticCheck"
execute "!javac -d C:\Users\LABIMD05\workspace\backhoe-nomvn2\bin\classes %"
endfunction
command! Javac :call Javac()
If the SyntasticCheck part is not necessary you can remove that.
Just put this in your .vimrc and then you can use :Javac to execute it.
Alternatively you could also put it in ~/.vim/ftplugin/java.vim if you want it to only be active when editing the java filetype.
I am using eclipse Luna with CVS for its synchronization and committing. However I keep getting a weird outcome from using it. For example my java class and file is named PrimeSieve. So when I commit the change, the file goes from being called PrimeSieve.java to PrimeSieve.java,v (the ,v gets appended). I don't quite understand or know where to get the resources to get the information to fix this. The reason I am trying to fix this is because when I run javac the ,v at the end gives me a bad flag warning with the compiler. Can anyone help me with this?
With CVS at the end of each file it appends a ,v because that is indication of the type of file it is. Any file with a ,v at the end of it is a history file.
For you to be able to make use of the .java class you would have to checkout the history file like so:
co yourJavaFile.java,v
This leaves you with
yourJavaFile.java
Hopefully this helps someone.
I had deleted a complete folder by mistake and had to use a data recovery software. However I could find only the .class files of my java program. The DE-compilers on net are giving error.
Even when I am trying to run the class file from command line using java..it gives incompatible magic value: 4292411361
1)How can I correct this error and run my program from the class file i just recovered?
2)How can I DE-compile this class file?
thanks
If it is a matter if decomiling the .class file, I would reccomend you user JD GUI
It is free and quite good in .class decompiling.
Then you can rebuild the Class file.
you can find error explanation of incompatible magic value error on https://stackoverflow.com/a/2390763/3131537
java compiler is very good tool for decompile class http://jd.benow.ca/
1)may be Your class file not recovered properly.if recovered properly try the below solution
2)we can use jad compiler to get the source file from .classfile.Download the jad compiler.we get a zip file,unzip it.you will find a .exe file in the folder.
place the .class file in the same folder.
use the command
jad -sjava Filename.class in cmd.
I'll try to illustrate the problem as simple as I can.
I have a JAR file, which I extracted using Winrar. (The jar file contains an open source android library).
I want to modify this JAR file by adding a new class to the library.
So here are my steps:
First, I created a class using Eclipse and set the package name same as the android's library package name.
Second, I copied this java File to the folder of the other java files in the library.
Third, I tried to compile the JAVA file via the CMD using javac.
The path of the new java file and the other .JAVA and .CLASS files of the library is: C:\com\example\core\
The name of the new java file would be: "MyNewClass.java"
The command I run via the CMD is: javac C:\com\example\core\MyNewClass.java
But, during the compilation I get many errors saying: Cannot find symbols.
I've been looking up for a solution of this problem but couldn't figure how to solve it and make the new JAR File having another class that I created seperately.
What am I missing?
As per earlier comments:
Rather than trying to modify the JAR, you can get access to the full source code of the Universal Image Loader library by cloning the repository using git or hitting "Download ZIP" on the righthand side of the page you linked.
Once you have the source, import the library in your IDE. From there on you'll be able to build the whole thing from scratch, make any adjustments/modifications you like, etc.
Your classpath might be wrong or there might be some mistake in package name.
When a Java program is being compiled the compiler it creates a list of all the identifiers in use. If it can't find what an identifier refers to it cannot complete the compilation. This is what the cannot find symbol error message is saying, it doesn't have enough information to piece together what the Java code wants to execute.
Try:
javac -cp com/* C:\com\example\core\MyNewClass.java
That should make the compiler aware of all the other classes under com/...