runtime

Writing and implementing new Java class files during run-time

∥☆過路亽.° 提交于 2019-11-29 14:20:23
问题 Is it possible to somehow 'import' a new Java class into a running program and make use of it? Could I have a program create a new File of type '.java' and then include it in the project files and reference it without having to restart the program? The following is an example of what I mean: import java.io.*; public class Program { File JClass = new File("JClass.java"); public static BufferedWriter out = null; public static void main(String[] args) { try { out = new BufferedWriter(new

How to change android application name and icon at runtime?

[亡魂溺海] 提交于 2019-11-29 14:15:54
问题 After installing an android app, is it possible to change app icon and name dynamically(at runtime) when you press a button in the app? This is the code so far.., getPackageManager().setComponentEnabledSetting( new ComponentName("com.example.badgemaste", "com.example.badgemaste.MainActivity"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); try { getPackageManager().setComponentEnabledSetting( new ComponentName("com.example.badgemaste", "com.example.badgemaste

How to find out the declared type of an identifier in Java?

安稳与你 提交于 2019-11-29 13:45:25
I have a simple class Apple extends from another simple class Fruit. At run-time, I could use Fruit fruit = new Apple(); fruit.getClass(); to get the actual type of fruit object, which is Apple.class. I could also use fruit instanceof Apple , and fruit instanceof Fruit to verify if this fruit object is an instance of Apple or Fruit. Both of these 2 expressions return true, which is normal. But is there a way to determine precisely the declared type of fruit identifier? Which in this case is Fruit . You're actually asking a question about the variable declaration of fruit rather than the actual

VBA in find function runtime error 91

♀尐吖头ヾ 提交于 2019-11-29 13:08:18
My question is concerning the runtime error 91 in VBA for excel. I've done some searching to no avail. My code is below. I have noted the section causing the error. Why is this happening, and how can i fix it and move on? Sub RemoveFooterRows(theFile) Dim found As Range Dim aggregateRow ''Error is from section below found = isItRow = Workbooks(theFile).Worksheets(1).Columns(1).Find _ ("Summary", Range("A1"), xlValues, xlPart, xlByRows, xlNext, False, , False) ''Error is from section above MsgBox ("val is " & found.Row) End Sub Sub RemoveFooterRows(theFile) Dim found As Range Set found =

Ada generics at run-time

狂风中的少年 提交于 2019-11-29 13:03:40
How would you instantiate a generic at runtime instead of at compile time. Example without using new. You cannot do this without use of new . You can do it in any declarative section, however that generic will only be extant for the duration of the scope of that declaritive section. for example (not compiled ada-like pseudocode): get(length) declare package stack is new stack_generic (max_stack_size => length); begin stack.push(); ... end; -- stack package no longer in scope. Does this help ? 来源: https://stackoverflow.com/questions/9630086/ada-generics-at-run-time

How do I get the number of members in a structure?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 12:58:36
I want to count the number of members in a structure. For example: typedef struct { char MrChar; int MrInt; long MrLong; } Bg_Typedef; Bg_Typedef FooStr; I create a function prototype that should return number of members in the structure int NumberOfMem(Bg_Typedef *psStructure); => NumberOfMem(&FooStr) should return 3 There is no way to do this that is inbuilt into the C language AFAIK. If you want to do this you would need to remember the number of members or hard code the number as return value of your function. C can tell you the size in bytes of your structs but not the number of members

Running Shell or System Command in JAVA

倖福魔咒の 提交于 2019-11-29 12:54:55
private void myFunction(String userName){ String fileName = this.generateFile(userName); String[] command = new String[4]; command[0] = "cmd"; command[1] = "/C"; command[2] = "dir"; command[3] = "7za a "+ userName+".7z "+ fileName +" -p"+this.password; try { Process p = Runtime.getRuntime().exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((s = stdError.readLine()) != null) { System.out.println(s); } ProcessBuilder proc = new ProcessBuilder

Why do books say, “the compiler allocates space for variables in memory”?

自闭症网瘾萝莉.ら 提交于 2019-11-29 12:35:22
问题 Why do books say, "the compiler allocates space for variables in memory". Isn't it the executable which does that? I mean, for example, if I write the following program, #include <iostream> using namespace std; int main() { int foo = 0; cout<<foo; return 0; } and compile it, and get an executable (let it be program.exe), now, if I run program.exe, this executable file will itself command to allocate some space for the variable foo. Won't it ? Please explain why books keep on saying, "the

Compile assembly in runtime and save dll in a folder

独自空忆成欢 提交于 2019-11-29 12:34:44
This is my code: Microsoft.CSharp.CSharpCodeProvider provider = new CSharpCodeProvider(); ICodeCompiler compiler = provider.CreateCompiler(); CompilerParameters compilerparams = new CompilerParameters(); compilerparams.GenerateInMemory = false; CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, code); if (results.Errors.HasErrors) { StringBuilder errors = new StringBuilder("Compiler Errors :\r\n"); foreach (CompilerError error in results.Errors ) { errors.AppendFormat("Line {0},{1}\t: {2}\n", error.Line, error.Column, error.ErrorText); } throw new Exception(errors

android request runtime permission to call action [closed]

落爺英雄遲暮 提交于 2019-11-29 12:29:00
i have code for call action and i need best way to declare run time permission ive tried many codes but i always get error here is my basic code any suggestion for make it work with runtime permission thanks in advance public class MainActivity extends Activity { private Button button; private EditText etPhoneno; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.buttonCall); etPhoneno = (EditText) findViewById(R.id.editText1); // add button listener button.setOnClickListener(new View