Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am kind of stuck in a dilemma. I want to create a tool that would generate code on the fly by taking various parameters from the user. The codes have a few similar features and few things need to be altered from one code to other to other. Based on the parameters, I can have 15 different codes. Till now I have been using file handling in Java to implement this as I have the created codes in different files but this doesn't seem to be a great method. Can you please suggest something that is better than this??
Since Java 1.6 you can compile in memory whatever you want. Take a look at this code:
http://code.google.com/p/cachos/source/browse/trunk/cachos/src/com/peyrona/cachos/InMemoryCompiler.java
http://code.google.com/p/cachos/source/browse/trunk/cachos/src/com/peyrona/cachos/InMemoryExecutor.java
In this example you can see how you can compile a source code stored in a String in memory, without using the disk.
Source (Spanish): http://www.javahispano.org/portada/2011/12/12/compilar-y-ejecutar-codigo-java-en-memoria.html
I think this is what you're looking for.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Is there a way to add custom rules to languageTool java API just by appending rules to grammar.xml and keeping it external to the java project?
I want to deploy my java project only once, but keep updating the grammar rules whenever required. I would like to keep the xml file (say grammar.xml) separately from the project, and access it through java code.
Thanks !
It should be possible to load XML rules with PatternRuleLoader and then activate them using JLanguageTool.addRule(). I'm not sure what will happen when you insert the same rule (i.e. a rule with the same id) more than once.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an assignment to find least used icons on desktop in Windows.
I need to code using JAVA. Which property of the File object in JAVA will be useful?
I have started analysis on it. A help will be much appreciated.
Have you checked out the File API? File#lastAccessTime is probably what you are looking for. Keep in mind that this only works in Java 7.
As for FREQUENCY of use, I do not think Windows keeps any data per-file... So you will have to rely on the last time of modification, possibly vs time of creation. The Java function you will need to rely on is lastModified(), eg
file_list[i].lastModified()
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I can't find the relative code to the native methods memchr, memcmp, memcpy, memmove, memset in Java. Could someone explain what do these methods stand for? What do they really do?
I want to acceed to the value pointed to by a variable in my program and I'm wondering if these methods could help me.
Thank you in advance.
Java native methods are not encouraged to use unless you can not get the things done using available java methods. Also implementations of native methods can be differ from java versions. If you really want to see them you just download the jdk with source code from openJDK and have a look at them. On the other hand you can have your own implementations for these native methods as well. Have a look at here
to get more details on how to override these native methods
There aren't any. Therefore your question about what they do doesn't make sense. The closest approach in Java is System.arraycopy().
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there any way that a .c and .h files can be used in eclipse? On a 32 bit xp,using jre1.6. I do not know any C. The code is about 500 lines
Not directly. You would need to know some c to add interface methods to be able to use JNI.
JNI is the key to use c or c++ code.
You can either invoke it using JNA or JNI, JNA generally being the easier one to use.
You'll need to alter your code though by reading up on the two technologies - it's not a magic bullet.
Your best bet is to rewrite the code.
Any kind of automated conversion usually produces unmaintainable code. If you opt for this solution, just pick one of these :
http://tech.novosoft-us.com/product_c2j.jsp
http://www.soften.ktu.lt/~stonis/c2java/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want a program to get information about RAM
How can i do that?
There's a couple of memory-related methods in the Runtime class, but note that they only give information about the amount of memory available to (or used by) the JVM, not the hardware it runs on.
Generally, Java is the wrong language to do this kind of thing, since it requires access to OS APIs that Java does not provide.
Most of the information you need will be contained in the Runtime class. Have a look at the link. It should be straightforward. If you run into problems with it, I will try to help you out further.