qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
9,006,994 |
I'd like to grant permissions to my jstatd on linux
The corresponding manual reads:
>
> To use this policy, copy the text into a file called jstatd.all.policy
> and run the jstatd server as follows:
>
>
> jstatd -J-Djava.security.policy=jstatd.all.policy
>
>
>
But where on linux should I place this jstatd.all.policy file?
|
2012/01/25
|
[
"https://Stackoverflow.com/questions/9006994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/677881/"
] |
As far as i remember you have to create the file in the same location as `jstatd` (...jdk/bin/) and it should work.
Update:
From [here](http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html):
>
> The user policy file is by default located at
>
>
> `user.home/.java.policy` (Solaris/Linux)
>
>
> `user.home\.java.policy` (Windows)
>
>
> Note: `user.home` refers to the value of the system property
> named `"user.home"`, which specifies the user's home directory.
>
>
>
|
You can also give a full path to the policy that would be used such as:
```
jstatd -p 1099 -J-Xrs -J-Djava.security.policy=C:\jstatd\tools.policy
```
This is helpful if you are on a shared machine and want a central place to add policies.
|
69,291,645 |
I'm trying to copy a database from a server (to which I'm connected through ssh) to my localhost. But all that I find is using the `copyDatabase()` method which is now deprecated, and the documentation doesn't explain how to do something similar (Or I didn't understand how to)
Also, I'd like to know how can I generalize that to also copy a DB from atlas if it's possible.
|
2021/09/22
|
[
"https://Stackoverflow.com/questions/69291645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10605742/"
] |
If you are using mongodb then its like
step 1: create a tunnel
```
ssh username@yourdomainOrIP -L 27017:localhost:27017
```
step 2 :
```
mongo
use admin
db.copyDatabase(<fromdb>,<todb>,"localhost:27017",<username>,<password>)
```
|
1. [mongodump](https://docs.mongodb.com/database-tools/mongodump/) dump either whole database or a specific collection
2. [mongorestore](https://docs.mongodb.com/database-tools/mongorestore/) restore to your local database
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
Assuming you're using Mongoid (you tagged it), you wouldn't want to use your first schema idea. It would be very inefficient for Mongoid to pull out those huge documents each time you wanted to look up a single little value.
What would probably be a much better model for you is:
```
class Log
include Mongoid::Document
field :type
field :date
field :pageviews, :type => Integer
field :time_on_page, :type => Integer
end
```
This would give you documents that look like:
```
{_id: ..., date: '2010-09-08', type: 'products', pageviews: 23, time_on_page: 178}
```
Don't worry about the number of documents - Mongo can handle billions of these. And you can index on type and date to easily find whatever figures you want.
Furthermore, this way it's a lot easier to update the records through the driver, without even pulling the record from the database. For example, on each pageview you could do something like:
```
Log.collection.update({'type' => 'products', 'date' => '2010-09-08'}, {'$inc' => {'pageview' => 1}})
```
|
I'm not a MongoDB expert, but 1000 isn't "huge". Also I would seriously doubt any difference between 1 top-level document containing 4000 total subelements, and 4 top-level documents each containing 1000 subelements -- one of those six-of-one vs. half-dozen-of-another issues.
Now if you were talking 1 document with 1,000,000 elements vs. 1000 documents each with 1000 elements, that's a different order of magnitude + there might be advantages of one vs. the other, either/both in storage time or query time.
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
I'm not a MongoDB expert, but 1000 isn't "huge". Also I would seriously doubt any difference between 1 top-level document containing 4000 total subelements, and 4 top-level documents each containing 1000 subelements -- one of those six-of-one vs. half-dozen-of-another issues.
Now if you were talking 1 document with 1,000,000 elements vs. 1000 documents each with 1000 elements, that's a different order of magnitude + there might be advantages of one vs. the other, either/both in storage time or query time.
|
You have talked about how you are going to update the data, but how do you plan to query it? It probably makes a difference on how you should structure your docs.
The problem with using embedded elements in arrays is that each time you add to that it may not fit in the current space allocated for the document. This will cause the (new) document to be reallocated and moved (that move will require re-writing any of the indexes for the doc).
I would generally suggest the second form you suggested, but it depends on the questions above.
Note: 4MB is an arbitrary limit and will be raised soon; you can recompile the server for any limit you want in fact.
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
I'm not a MongoDB expert, but 1000 isn't "huge". Also I would seriously doubt any difference between 1 top-level document containing 4000 total subelements, and 4 top-level documents each containing 1000 subelements -- one of those six-of-one vs. half-dozen-of-another issues.
Now if you were talking 1 document with 1,000,000 elements vs. 1000 documents each with 1000 elements, that's a different order of magnitude + there might be advantages of one vs. the other, either/both in storage time or query time.
|
It seems your design closely resembles the relational table schema.

So every document added will be a separate entry in a collection having its own identifier. Though mongo document size is limited to 4 MB, its mostly enough to accommodate plain text documents. And you don't have to worry about number of growing documents in mongo, thats the essence of document based databases.
Only thing you need to worry about is size of the db collection. Its limited to 2GB for 32 bit systems. Because MongoDB uses memory-mapped files, as they're tied to the available memory addressing. This is not a problem with 64 bit systems.
Hope this helps
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
I'm not a MongoDB expert, but 1000 isn't "huge". Also I would seriously doubt any difference between 1 top-level document containing 4000 total subelements, and 4 top-level documents each containing 1000 subelements -- one of those six-of-one vs. half-dozen-of-another issues.
Now if you were talking 1 document with 1,000,000 elements vs. 1000 documents each with 1000 elements, that's a different order of magnitude + there might be advantages of one vs. the other, either/both in storage time or query time.
|
Again this depends on your use case of querying. If you really care about single item, such as products per day:
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
then you could include multiple days in one date.
{ type: 'products', { date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 } } }
We use something like this:
{ type: 'products', "2010" : { "09" : { "08" : data: { pageviews: 23, timeOnPage: 178 }} } } }
So we can increment by day: { "$inc" : { "2010.09.08.data.pageviews" : 1 } }
Maybe seems complicated, but the advantage is you can store all data about a 'type' in 1 record. So you can retrieve a single record and have all information.
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
Assuming you're using Mongoid (you tagged it), you wouldn't want to use your first schema idea. It would be very inefficient for Mongoid to pull out those huge documents each time you wanted to look up a single little value.
What would probably be a much better model for you is:
```
class Log
include Mongoid::Document
field :type
field :date
field :pageviews, :type => Integer
field :time_on_page, :type => Integer
end
```
This would give you documents that look like:
```
{_id: ..., date: '2010-09-08', type: 'products', pageviews: 23, time_on_page: 178}
```
Don't worry about the number of documents - Mongo can handle billions of these. And you can index on type and date to easily find whatever figures you want.
Furthermore, this way it's a lot easier to update the records through the driver, without even pulling the record from the database. For example, on each pageview you could do something like:
```
Log.collection.update({'type' => 'products', 'date' => '2010-09-08'}, {'$inc' => {'pageview' => 1}})
```
|
You have talked about how you are going to update the data, but how do you plan to query it? It probably makes a difference on how you should structure your docs.
The problem with using embedded elements in arrays is that each time you add to that it may not fit in the current space allocated for the document. This will cause the (new) document to be reallocated and moved (that move will require re-writing any of the indexes for the doc).
I would generally suggest the second form you suggested, but it depends on the questions above.
Note: 4MB is an arbitrary limit and will be raised soon; you can recompile the server for any limit you want in fact.
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
Assuming you're using Mongoid (you tagged it), you wouldn't want to use your first schema idea. It would be very inefficient for Mongoid to pull out those huge documents each time you wanted to look up a single little value.
What would probably be a much better model for you is:
```
class Log
include Mongoid::Document
field :type
field :date
field :pageviews, :type => Integer
field :time_on_page, :type => Integer
end
```
This would give you documents that look like:
```
{_id: ..., date: '2010-09-08', type: 'products', pageviews: 23, time_on_page: 178}
```
Don't worry about the number of documents - Mongo can handle billions of these. And you can index on type and date to easily find whatever figures you want.
Furthermore, this way it's a lot easier to update the records through the driver, without even pulling the record from the database. For example, on each pageview you could do something like:
```
Log.collection.update({'type' => 'products', 'date' => '2010-09-08'}, {'$inc' => {'pageview' => 1}})
```
|
It seems your design closely resembles the relational table schema.

So every document added will be a separate entry in a collection having its own identifier. Though mongo document size is limited to 4 MB, its mostly enough to accommodate plain text documents. And you don't have to worry about number of growing documents in mongo, thats the essence of document based databases.
Only thing you need to worry about is size of the db collection. Its limited to 2GB for 32 bit systems. Because MongoDB uses memory-mapped files, as they're tied to the available memory addressing. This is not a problem with 64 bit systems.
Hope this helps
|
3,689,201 |
Since we can structure a MongoDB any way we want, we can do it this way
```
{ products:
[
{ date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }},
{ date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
],
brands:
[
{ date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }},
{ date: "2010-09-09", data: { pageviews: 61, timeOnPage: 876 }}
]
}
```
so as we add data to it day after day, the `products` document and `brands` document will become bigger and bigger. After 3 years, there will be a thousand elements in `products` and in `brands`. Is it not good for MongoDB? Should we break it down more into 4 documents:
```
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
{ type: 'products', date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}
{ type: 'brands', date: "2010-09-08", data: { pageviews: 61, timeOnPage: 876 }}
```
So that after 3 years, there will be just 2000 "documents"?
|
2010/09/11
|
[
"https://Stackoverflow.com/questions/3689201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325418/"
] |
Assuming you're using Mongoid (you tagged it), you wouldn't want to use your first schema idea. It would be very inefficient for Mongoid to pull out those huge documents each time you wanted to look up a single little value.
What would probably be a much better model for you is:
```
class Log
include Mongoid::Document
field :type
field :date
field :pageviews, :type => Integer
field :time_on_page, :type => Integer
end
```
This would give you documents that look like:
```
{_id: ..., date: '2010-09-08', type: 'products', pageviews: 23, time_on_page: 178}
```
Don't worry about the number of documents - Mongo can handle billions of these. And you can index on type and date to easily find whatever figures you want.
Furthermore, this way it's a lot easier to update the records through the driver, without even pulling the record from the database. For example, on each pageview you could do something like:
```
Log.collection.update({'type' => 'products', 'date' => '2010-09-08'}, {'$inc' => {'pageview' => 1}})
```
|
Again this depends on your use case of querying. If you really care about single item, such as products per day:
{ type: 'products', date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}
then you could include multiple days in one date.
{ type: 'products', { date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 } } }
We use something like this:
{ type: 'products', "2010" : { "09" : { "08" : data: { pageviews: 23, timeOnPage: 178 }} } } }
So we can increment by day: { "$inc" : { "2010.09.08.data.pageviews" : 1 } }
Maybe seems complicated, but the advantage is you can store all data about a 'type' in 1 record. So you can retrieve a single record and have all information.
|
233,449 |
so I am new to blender and I have been trying for days to get vertex paint to work on my sculpted object. Ive followed multiple tutorials but it just wont show up.
UPDATE:so now I am able to draw on my figure but I edited my character more in sculpt mode but when I go back to vertex paint mode the edits get undone and it reverts back to the old character? But then its back to the new character when I go into sculpt mode again
I am also using blender 2.931
thank you
here is my file sorry I dont know how to upload it properly
<https://drive.google.com/file/d/1QP-lvnOZG2e6pbGRKcq46lyGpzp6ZuXC/view?usp=sharing>
|
2021/08/04
|
[
"https://blender.stackexchange.com/questions/233449",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/129981/"
] |
I can see that you have the faces in the upper right corner enabled:
[](https://i.stack.imgur.com/IuKAc.png)
This works kind of as a mask.
You can disable it.
If you want to use a mask, then
* switch to Edit mode
* select the faces that should be affected by the paint brush
* switch back to Vertex Paint
* now only the selected faces should be paintable
Probably you have selected none of the faces and therefore you can't paint anything.
|
Answer to your second question:
[](https://i.stack.imgur.com/e3zgS.png)
In the properties window in the modifier tab I found the Multires modifier. I never worked with that before, but as I can see there is a different value for "level viewport" and "sculpt".
[](https://i.stack.imgur.com/BQEKW.png)
Set the "level viewport" to the same value as "sculpt" and then you should see no difference any more when you switch between these modes.
|
38,546,642 |
I have a simple model:
```
class Receipt
include ActiveModel::Serialization
attr_accessor :products
end
```
and my controller is doing:
```
def create
respond_with receipt, :serializer => ReceiptSerializer
end
```
and the serializer:
```
class ReceiptSerializer < ActiveModel::Serializer
attributes :products
end
```
and I get:
>
>
> ```
> NoMethodError:
> undefined method `to_model' for #<Receipt:0x007f99bcb3b6d8>
>
> ```
>
>
Yet if I change my controller to:
```
def create
json = ReceiptSerializer.new(receipt)
render :json => json
end
```
Then everything works fine... what is happening???
I was using active\_model\_serializers 0.9.3, but just tried 0.10.2, and the results are the same.
|
2016/07/23
|
[
"https://Stackoverflow.com/questions/38546642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/594763/"
] |
In all the documentation I've read and personal implementation I use `render json:` instead of `respond_with`.
```
render json: receipt, serializer: ReceiptSerializer
```
I believe that `respond_with` has been removed from rails and isn't considered a best practice anymore but I can't find a link to validate that claim.
|
I'm not totally sure, but it seems in your Receipt PORO, you should rather include: `ActiveModel::SerializerSupport`.
I can't confirm if that works for active\_model\_serializers 0.10.2 though
|
8,843,611 |
I have the following (simplified for this example) Django models:
```
class Ingredient(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class RecipeIngredient(models.Model):
quantity = models.DecimalField(max_digits=5, decimal_places=3)
unit_of_measure = models.ForeignKey(UnitOfMeasure)
ingredient = models.ForeignKey(Ingredient)
comment = models.CharField(max_length = 40, blank=True)
def __unicode__(self):
return self.id
```
And I have the following form:
```
class RecipeIngredientForm(ModelForm):
class Meta:
model = RecipeIngredient
def __init__(self, *args, **kwargs):
super(RecipeIngredientForm, self).__init__(*args, **kwargs)
self.fields['quantity'].widget = forms.TextInput(attrs={'size':'6'})
self.fields['ingredient'].widget = forms.TextInput(attrs={'size':'30'})
self.fields['comment'].widget = forms.TextInput(attrs={'size':'38'})
```
When I view the form, the ingredient is displayed by its id value, not its name. How can I display the name, rather than the id?
UPDATE
A solution (more elegant ideas still welcome) is to subclass the TextInput widget and use the value to get the Ingredient name:
```
class IngredientInput(forms.TextInput):
def render(self, name, value, attrs=None):
new=Ingredient.objects.get(pk=value).name
value=new
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_unicode(self._format_value(value))
return mark_safe(u'<input%s />' % flatatt(final_attrs))
```
|
2012/01/12
|
[
"https://Stackoverflow.com/questions/8843611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382928/"
] |
I solved this use case by overriding a field's queryset within `__init__` on the Form. A select input is still displayed but it only has one option. I had the same issue as the OP by too many options for the select.
```
class PaymentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(PaymentForm, self).__init__(*args, **kwargs)
instance = kwargs.get("instance", None)
if instance and instance.id and instance.reconciled_by:
self.fields["reconciled_by"].queryset = User.objects.filter(
id=instance.reconciled_by.id
)
```
|
IT displays the id because you said so:
```
class RecipeIngredient(models.Model):
def __unicode__(self):
return self.id
```
EDIT:
...and also, because you use a TextInput
```
self.fields['ingredient'].widget = forms.TextInput(attrs={'size':'30'})
```
I guess you need this:
<https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelchoicefield>
|
8,843,611 |
I have the following (simplified for this example) Django models:
```
class Ingredient(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class RecipeIngredient(models.Model):
quantity = models.DecimalField(max_digits=5, decimal_places=3)
unit_of_measure = models.ForeignKey(UnitOfMeasure)
ingredient = models.ForeignKey(Ingredient)
comment = models.CharField(max_length = 40, blank=True)
def __unicode__(self):
return self.id
```
And I have the following form:
```
class RecipeIngredientForm(ModelForm):
class Meta:
model = RecipeIngredient
def __init__(self, *args, **kwargs):
super(RecipeIngredientForm, self).__init__(*args, **kwargs)
self.fields['quantity'].widget = forms.TextInput(attrs={'size':'6'})
self.fields['ingredient'].widget = forms.TextInput(attrs={'size':'30'})
self.fields['comment'].widget = forms.TextInput(attrs={'size':'38'})
```
When I view the form, the ingredient is displayed by its id value, not its name. How can I display the name, rather than the id?
UPDATE
A solution (more elegant ideas still welcome) is to subclass the TextInput widget and use the value to get the Ingredient name:
```
class IngredientInput(forms.TextInput):
def render(self, name, value, attrs=None):
new=Ingredient.objects.get(pk=value).name
value=new
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_unicode(self._format_value(value))
return mark_safe(u'<input%s />' % flatatt(final_attrs))
```
|
2012/01/12
|
[
"https://Stackoverflow.com/questions/8843611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382928/"
] |
I had a similar problem and solved very similarly like this (Python 3) this also used the super class to do the rendering rather than rewriting it out again.
I have added a feature which I wanted which is to make the field read only, I left it it as I thought it might be useful for editing for what you want:
```
class IngredientInput(forms.TextInput):
def render(self, name, value, attrs=None):
new=Ingredient.objects.get(pk=value).name
value = self._format_value(new)
attrs['readonly'] = True
return super(IngredientInput, self).render(name, value, attrs)
```
|
IT displays the id because you said so:
```
class RecipeIngredient(models.Model):
def __unicode__(self):
return self.id
```
EDIT:
...and also, because you use a TextInput
```
self.fields['ingredient'].widget = forms.TextInput(attrs={'size':'30'})
```
I guess you need this:
<https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelchoicefield>
|
8,843,611 |
I have the following (simplified for this example) Django models:
```
class Ingredient(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class RecipeIngredient(models.Model):
quantity = models.DecimalField(max_digits=5, decimal_places=3)
unit_of_measure = models.ForeignKey(UnitOfMeasure)
ingredient = models.ForeignKey(Ingredient)
comment = models.CharField(max_length = 40, blank=True)
def __unicode__(self):
return self.id
```
And I have the following form:
```
class RecipeIngredientForm(ModelForm):
class Meta:
model = RecipeIngredient
def __init__(self, *args, **kwargs):
super(RecipeIngredientForm, self).__init__(*args, **kwargs)
self.fields['quantity'].widget = forms.TextInput(attrs={'size':'6'})
self.fields['ingredient'].widget = forms.TextInput(attrs={'size':'30'})
self.fields['comment'].widget = forms.TextInput(attrs={'size':'38'})
```
When I view the form, the ingredient is displayed by its id value, not its name. How can I display the name, rather than the id?
UPDATE
A solution (more elegant ideas still welcome) is to subclass the TextInput widget and use the value to get the Ingredient name:
```
class IngredientInput(forms.TextInput):
def render(self, name, value, attrs=None):
new=Ingredient.objects.get(pk=value).name
value=new
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
if value != '':
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_unicode(self._format_value(value))
return mark_safe(u'<input%s />' % flatatt(final_attrs))
```
|
2012/01/12
|
[
"https://Stackoverflow.com/questions/8843611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382928/"
] |
I solved this use case by overriding a field's queryset within `__init__` on the Form. A select input is still displayed but it only has one option. I had the same issue as the OP by too many options for the select.
```
class PaymentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(PaymentForm, self).__init__(*args, **kwargs)
instance = kwargs.get("instance", None)
if instance and instance.id and instance.reconciled_by:
self.fields["reconciled_by"].queryset = User.objects.filter(
id=instance.reconciled_by.id
)
```
|
I had a similar problem and solved very similarly like this (Python 3) this also used the super class to do the rendering rather than rewriting it out again.
I have added a feature which I wanted which is to make the field read only, I left it it as I thought it might be useful for editing for what you want:
```
class IngredientInput(forms.TextInput):
def render(self, name, value, attrs=None):
new=Ingredient.objects.get(pk=value).name
value = self._format_value(new)
attrs['readonly'] = True
return super(IngredientInput, self).render(name, value, attrs)
```
|
344,459 |
How can I do this question?
$$\sqrt{x}-2\sqrt[4]{x}-8 = 0$$
Can I solve this?
I tried to multiply everything by $x^4$, and got
$$8x^4+x^3 -2x = 0$$
I don't know how to proceed from here.
|
2013/03/28
|
[
"https://math.stackexchange.com/questions/344459",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/69840/"
] |
When multiplying powers, we have to ADD exponents: $x^a x^b = x^{a + b}$. Instead, try letting $x = u^4$, so
$$
\sqrt{x} - 2\sqrt[4]{x} - 8 = 0
$$
becomes
$$
u^2 - 2u - 8 = 0,
$$
which you can solve using the quadratic formula (although you might introduce extraneous solutions).
|
**Hint**:
$x^{\frac{1}{4}}=k$
$ \sqrt{(x)}=k^2$
Or you can just keep the equation as it is:
$\sqrt{x}-2\sqrt[4]{x}-8=0 \implies \sqrt{x}-4\sqrt[4]{x}+2\sqrt[4]{x}-8=0$. Factorize it.
|
344,459 |
How can I do this question?
$$\sqrt{x}-2\sqrt[4]{x}-8 = 0$$
Can I solve this?
I tried to multiply everything by $x^4$, and got
$$8x^4+x^3 -2x = 0$$
I don't know how to proceed from here.
|
2013/03/28
|
[
"https://math.stackexchange.com/questions/344459",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/69840/"
] |
Let $\sqrt[4]x=u$. This gives $\sqrt x = u^2$.
Solve the quadratic equation in $u$. You get the values for $u$ as $4$ or $-2$.
Since $\sqrt[4]x$ cannot be negative, it is equal to $4$.
Hence $x = 4^4 = 256$
|
When multiplying powers, we have to ADD exponents: $x^a x^b = x^{a + b}$. Instead, try letting $x = u^4$, so
$$
\sqrt{x} - 2\sqrt[4]{x} - 8 = 0
$$
becomes
$$
u^2 - 2u - 8 = 0,
$$
which you can solve using the quadratic formula (although you might introduce extraneous solutions).
|
344,459 |
How can I do this question?
$$\sqrt{x}-2\sqrt[4]{x}-8 = 0$$
Can I solve this?
I tried to multiply everything by $x^4$, and got
$$8x^4+x^3 -2x = 0$$
I don't know how to proceed from here.
|
2013/03/28
|
[
"https://math.stackexchange.com/questions/344459",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/69840/"
] |
Let $\sqrt[4]x=u$. This gives $\sqrt x = u^2$.
Solve the quadratic equation in $u$. You get the values for $u$ as $4$ or $-2$.
Since $\sqrt[4]x$ cannot be negative, it is equal to $4$.
Hence $x = 4^4 = 256$
|
**Hint**:
$x^{\frac{1}{4}}=k$
$ \sqrt{(x)}=k^2$
Or you can just keep the equation as it is:
$\sqrt{x}-2\sqrt[4]{x}-8=0 \implies \sqrt{x}-4\sqrt[4]{x}+2\sqrt[4]{x}-8=0$. Factorize it.
|
13,102,244 |
I'm looking for what is the most idiomatic way of naming a method that for instance converts the data of a class to xml.
If I were doing this in Ruby I would make a method named `to_xml` for instance, but I've seen several different ways of doing this in Python. `toxml`, `to_xml`, `xml` and `toXML`, for different outputs than XML, but just extrapolating what it would look like for XML.
And taken how you convert objects for native Python objects (`str()` etc) I don't really know what would be the idiomatic way.
Personally I would just continue and use `to_xml` since that's what I'm used to, but would that be unexpected to an experienced Python programmer?
|
2012/10/27
|
[
"https://Stackoverflow.com/questions/13102244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68035/"
] |
[PEP8](http://www.python.org/dev/peps/pep-0008/#method-names-and-instance-variables) recommends `to_xml`:
>
> Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.
>
>
>
|
If you go through the [Python Style Guide - PEP8](http://www.python.org/dev/peps/pep-0008/), it is recommended to use all letters in lowercase, with an underscore separating each word.
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Instead of using Tomcat from Macports download Tomcat from Apache.
6.0: <http://tomcat.apache.org/download-60.cgi>
7.0: <http://tomcat.apache.org/download-70.cgi>
|
Edit to Bruno's answer which was finally what worked for me after quite a bit of maven trial and error.
If you are using 1.7 then you should be able to change revision to 1.7. I do not know if this is still a problem in Java 1.7 though.
```
sudo sh -c '$(j_home=$(/usr/libexec/java_home -v 1.6) && ln -sf ${j_home}/../Classes/classes.jar ${j_home}/../Classes/tools.jar && ln -sf ${j_home}/../Classes ${j_home}/../lib)'
```
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
This is similar to Bruno's answer above; however, I am not a big fan of symlinking the absolute path. Here is how I handle the symlinks:
```
cd /Library/Java/JavaVirtualMachines/<jdk version>/Contents/Home
sudo ln -s lib Classes
cd lib/
sudo ln -s tools.jar classes.jar
```
That makes it easier then symlinking absolute paths.
|
Edit to Bruno's answer which was finally what worked for me after quite a bit of maven trial and error.
If you are using 1.7 then you should be able to change revision to 1.7. I do not know if this is still a problem in Java 1.7 though.
```
sudo sh -c '$(j_home=$(/usr/libexec/java_home -v 1.6) && ln -sf ${j_home}/../Classes/classes.jar ${j_home}/../Classes/tools.jar && ln -sf ${j_home}/../Classes ${j_home}/../lib)'
```
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Here is my tested solution, which implies no change in maven config, just add symbolic links:
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/classes.jar
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/tools.jar
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../lib
Enjoy!
Bruno
|
Can't find any references to it on the interweb, but my Mac 1.7 and 1.8 jdk's now have tools.jar.
>
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_12.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_51.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_60.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_79.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.8.0\_51.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.8.0\_92.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
>
>
>
classes.jar is only present in mac 1.6 jdk.
--Erik
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Here is my tested solution, which implies no change in maven config, just add symbolic links:
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/classes.jar
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/tools.jar
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../lib
Enjoy!
Bruno
|
I faced the same problem, and resolved it differently.
* First check that the **java\_home** is set as
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents` and not
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home`
* Add the cobertura plugin, make sure `systemPath` is correctly ref the location of `classes.jar`
```
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java_home}/Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</plugin>
```
* Add the dependency and exclude tools
```
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
```
* Finally add the following profiles
```
<profiles>
<profile>
<id>standard-jdk</id>
<activation>
<file>
<exists>${java_home}/Home/lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Home/lib/tools.jar</tools-jar>
</properties>
</profile>
<profile>
<id>apple-jdk</id>
<activation>
<file>
<exists>${java_home}/Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Classes/classes.jar</tools-jar>
</properties>
</profile>
```
Now run maven and it should successfully generate the Cobertura reports!
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
This is similar to Bruno's answer above; however, I am not a big fan of symlinking the absolute path. Here is how I handle the symlinks:
```
cd /Library/Java/JavaVirtualMachines/<jdk version>/Contents/Home
sudo ln -s lib Classes
cd lib/
sudo ln -s tools.jar classes.jar
```
That makes it easier then symlinking absolute paths.
|
Well, you search for 'tools.jar', with grep for instance. If the place where classes.jar is, where tools.jar was expected, you could just change the word.
Another idea is, to create a symbolic link from classes.jar to tools.jar, if you have enough privileges and the file system(s) on MacOS support this. Else: copy. Might be more easy, but not be forgotten for updates, maybe.
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Here is my tested solution, which implies no change in maven config, just add symbolic links:
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/classes.jar
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes/tools.jar
* ln -s /Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../Classes
/Library/Java/JavaVirtualMachines/1.6.0\_38-b04-436.jdk/Contents/Home/../lib
Enjoy!
Bruno
|
Well, you search for 'tools.jar', with grep for instance. If the place where classes.jar is, where tools.jar was expected, you could just change the word.
Another idea is, to create a symbolic link from classes.jar to tools.jar, if you have enough privileges and the file system(s) on MacOS support this. Else: copy. Might be more easy, but not be forgotten for updates, maybe.
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
This is similar to Bruno's answer above; however, I am not a big fan of symlinking the absolute path. Here is how I handle the symlinks:
```
cd /Library/Java/JavaVirtualMachines/<jdk version>/Contents/Home
sudo ln -s lib Classes
cd lib/
sudo ln -s tools.jar classes.jar
```
That makes it easier then symlinking absolute paths.
|
Can't find any references to it on the interweb, but my Mac 1.7 and 1.8 jdk's now have tools.jar.
>
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_12.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_51.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_60.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.7.0\_79.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.8.0\_51.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/jdk1.8.0\_92.jdk/Contents/Home/lib/tools.jar
> /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
>
>
>
classes.jar is only present in mac 1.6 jdk.
--Erik
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
This is similar to Bruno's answer above; however, I am not a big fan of symlinking the absolute path. Here is how I handle the symlinks:
```
cd /Library/Java/JavaVirtualMachines/<jdk version>/Contents/Home
sudo ln -s lib Classes
cd lib/
sudo ln -s tools.jar classes.jar
```
That makes it easier then symlinking absolute paths.
|
Instead of using Tomcat from Macports download Tomcat from Apache.
6.0: <http://tomcat.apache.org/download-60.cgi>
7.0: <http://tomcat.apache.org/download-70.cgi>
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Instead of using Tomcat from Macports download Tomcat from Apache.
6.0: <http://tomcat.apache.org/download-60.cgi>
7.0: <http://tomcat.apache.org/download-70.cgi>
|
I faced the same problem, and resolved it differently.
* First check that the **java\_home** is set as
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents` and not
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home`
* Add the cobertura plugin, make sure `systemPath` is correctly ref the location of `classes.jar`
```
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java_home}/Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</plugin>
```
* Add the dependency and exclude tools
```
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
```
* Finally add the following profiles
```
<profiles>
<profile>
<id>standard-jdk</id>
<activation>
<file>
<exists>${java_home}/Home/lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Home/lib/tools.jar</tools-jar>
</properties>
</profile>
<profile>
<id>apple-jdk</id>
<activation>
<file>
<exists>${java_home}/Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Classes/classes.jar</tools-jar>
</properties>
</profile>
```
Now run maven and it should successfully generate the Cobertura reports!
|
5,616,325 |
hello I am trying to debug the crash of an Android app an outdated android app that I have been working on. The app is the Jython Interpreter for Android so far I have managed to compile a debug binary and am hoping some one could shed some light on this error message of logcat thank you
```
I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.python.util/.
Jythonroid }
I/ActivityManager( 51): Start proc org.python.util for activity org.python.uti
l/.Jythonroid: pid=190 uid=10028 gids={1015}
D/dalvikvm( 30): GC freed 284 objects / 10864 bytes in 318ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 117ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 96ms
D/dalvikvm( 51): GC freed 13347 objects / 617528 bytes in 195ms
I/ARMAssembler( 51): generated scanline__00000177:03515104_00000001_00000000 [
73 ipp] (95 ins) at [0x4c0640:0x4c07bc] in 894130 ns
I/ARMAssembler( 51): generated scanline__00000077:03545404_00000004_00000000 [
47 ipp] (67 ins) at [0x4c19b0:0x4c1abc] in 640894 ns
D/AndroidRuntime( 190): Shutting down VM
W/dalvikvm( 190): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime( 190): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 190): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{org.python.util/org.python.util.Jythonroid}: java.lang.IllegalStateE
xception: The specified child already has a parent. You must call removeView() o
n the child's parent first.
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2496)
E/AndroidRuntime( 190): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2512)
E/AndroidRuntime( 190): at android.app.ActivityThread.access$2200(Activi
tyThread.java:119)
E/AndroidRuntime( 190): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1863)
E/AndroidRuntime( 190): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 190): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 190): at android.app.ActivityThread.main(ActivityThrea
d.java:4363)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 190): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 190): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:618)
E/AndroidRuntime( 190): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 190): Caused by: java.lang.IllegalStateException: The specifi
ed child already has a parent. You must call removeView() on the child's parent
first.
E/AndroidRuntime( 190): at android.view.ViewGroup.addViewInner(ViewGroup
.java:1861)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1756)
E/AndroidRuntime( 190): at android.view.ViewGroup.addView(ViewGroup.java
:1736)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:217)
E/AndroidRuntime( 190): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 190): at android.app.Activity.setContentView(Activity.
java:1633)
E/AndroidRuntime( 190): at org.python.util.Jythonroid.onCreate(Jythonroi
d.java:251)
E/AndroidRuntime( 190): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime( 190): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2459)
E/AndroidRuntime( 190): ... 11 more
I/Process ( 51): Sending signal. PID: 190 SIG: 3
I/dalvikvm( 190): threadid=7: reacting to signal 3
E/dalvikvm( 190): Unable to open stack trace file '/data/anr/traces.txt': Permi
ssion denied
I/ARMAssembler( 51): generated scanline__00000077:03515104_00000000_00000000 [
33 ipp] (47 ins) at [0x4c1ac0:0x4c1b7c] in 405177 ns
I/ARMAssembler( 51): generated scanline__00000177:03515104_00001001_00000000 [
91 ipp] (114 ins) at [0x492b80:0x492d48] in 494049 ns
W/ActivityManager( 51): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 51): Activity idle timeout for HistoryRecord{43db26a8 org.p
ython.util/.Jythonroid}
D/dalvikvm( 97): GC freed 965 objects / 44888 bytes in 164ms
I/Process ( 190): Sending signal. PID: 190 SIG: 9
I/ActivityManager( 51): Process org.python.util (pid 190) has died.
I/UsageStats( 51): Unexpected resume of com.android.launcher while already res
umed in org.python.util
W/InputManagerService( 51): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@43c6ef58
E/gralloc ( 51): [unregister] handle 0x3d0690 still locked (state=40000001)
```
Below is the onCreate method
cheers
Below is the onCreate Method
```
/**
* provide an interactive shell in the screen
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
shell = (EditText) findViewById(R.id.shell);
// shell=new ShellEditer(this, null, null);
setContentView(shell);
shell.setEnabled(false);
initializeShell(shell);
Handler hd = new Handler() {
public void handleMessage(Message msg) {
if (msg.getData().containsKey("initial")) {
alert("initialized");
shell.setEnabled(true);
} else {
shell.append("\n"+(String) msg.getData().get("result"));
}
}
};
//running the backend
new Thread(new Runnable() {
public void run() {
try {
Runtime.getRuntime().exec(
"dalvikvm -classpath "
+ "/data/app/Jythonroid.apk "
+ "org.python.util.JythonServer");
} catch (IOException e) {
e.printStackTrace();
}
}
}, "JythonServer").start();
shellclient = new ShellClient(this, hd);
new Thread(shellclient).start();
}
```
I am now getting the following error trying to run this app from the shell any idea how I can achieve what I am after
```
$ dalvikvm -classpath org.python.util.apk org.python.util.jython
dalvikvm -classpath org.python.util.apk org.python.util.jython
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in loader da
lvik.system.PathClassLoader@4001e590
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 1 more
$
```
it seems it can't find the Path and honestly I am not sure where it is. In the FixMe.java file of my project I set it to
```
public static String apkpath = "/data/app";
public static String apkname = "org.python.util.apk";
public static String apppath = apkpath + apkname;
public static String tmpdirpath = "/data/jythonroid/";
```
But I am unsure that I can write to those paths what should I set those to \*cheers
last update I solved most my problems and now get a shell just I get a few errors when running it any ideas how to fix these cheers
```
# dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
dalvikvm -classpath /data/app/org.python.util.apk org.python.util.jython
Jython 2.2.1 on java0
Apr 11, 2011 7:40:14 PM java.io.BufferedReader <init>
INFO: Default buffer size used in BufferedReader constructor. It would be better
to be explicit if an 8k-char buffer is required.
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:356)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:357)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexFile.<init>(DexFile.java:57)
at org.python.debug.FixMe.getClassByName(FixMe.java:104)
at org.python.debug.FixMe.getDexClass(FixMe.java:360)
at org.python.core.BytecodeLoader2.loadClassFromBytes(BytecodeLoader2.ja
va:44)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:92)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:103)
at org.python.core.Py.compile_flags(Py.java:1685)
at org.python.core.Py.compile_flags(Py.java:1698)
at org.python.core.Py.compile_flags(Py.java:1706)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:7
3)
at org.python.util.jython.main(jython.java:251)
at dalvik.system.NativeStart.main(Native Method)
>>>
```
|
2011/04/11
|
[
"https://Stackoverflow.com/questions/5616325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701474/"
] |
Well, you search for 'tools.jar', with grep for instance. If the place where classes.jar is, where tools.jar was expected, you could just change the word.
Another idea is, to create a symbolic link from classes.jar to tools.jar, if you have enough privileges and the file system(s) on MacOS support this. Else: copy. Might be more easy, but not be forgotten for updates, maybe.
|
I faced the same problem, and resolved it differently.
* First check that the **java\_home** is set as
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents` and not
`/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home`
* Add the cobertura plugin, make sure `systemPath` is correctly ref the location of `classes.jar`
```
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java_home}/Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</plugin>
```
* Add the dependency and exclude tools
```
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
```
* Finally add the following profiles
```
<profiles>
<profile>
<id>standard-jdk</id>
<activation>
<file>
<exists>${java_home}/Home/lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Home/lib/tools.jar</tools-jar>
</properties>
</profile>
<profile>
<id>apple-jdk</id>
<activation>
<file>
<exists>${java_home}/Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Classes/classes.jar</tools-jar>
</properties>
</profile>
```
Now run maven and it should successfully generate the Cobertura reports!
|
56,188,610 |
[](https://i.stack.imgur.com/VVKJm.jpg)Grunt is running and detecting the change but the compilation is not happening due to the error "Could not find an option named "sourcemap"
Ruby was not installed since it was required before, I installed it.
Updated all the node packages inside the package.json file. SCSS/CSS files are in the correct path as fas as I know, not sure what could be the issue.
```js
ui = {
'grunt' :
{
'js_files' :
[
'web/webroot/_ui/responsive/theme-blue/razer/js/jquery-ui-1.11.2.custom.min.js'
]
}
}
//'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Compile Sass
sass: {
options: {
sourcemap: 'none'
},
compile: {
files: {
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.scss',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.home.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.home.scss',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.branding.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.branding.scss',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.whitepdp.css': 'web/webroot/_ui/responsive/theme-blue/razer/sass/main.whitepdp.scss'
}
}
},
//Minify css
cssmin: {
target: {
files: [
{
src: [
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.css'
},
{
src: [
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.home.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.home.css'
},
{
src: [
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.branding.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.branding.css'
},
{
src: [
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/main.whitepdp.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.carousel.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/owl.theme.default.min.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/simplebar.css',
'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/styles.css'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/stylesheets/mainmin.whitepdp.css'
}
]
}
},
imagemin: { // Task
dynamic: { // Another target
files: [{
expand: true, // Enable dynamic expansion
cwd: 'web/webroot/_ui/responsive/theme-blue/razer/images/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'web/webroot/_ui/responsive/theme-blue/razer/images/' // Destination path prefix
}]
}
},
//Uglify js
uglify: {
build: {
files: [{
src: ui.grunt.js_files,
dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined.js'
}],
files: [{
src: [
'web/webroot/_ui/responsive/common/js/jquery-2.1.1.min.js'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined_lib.js'
}],
files: [{
src: [
'web/webroot/_ui/responsive/common/js/jquery-2.1.1.min.js'
],
dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined_lib.js'
}]
},
debug: {
options: {
beautify: false,
mangle: false,
compress: true
},
files: [{
src: ui.grunt.js_files,
dest: 'web/webroot/_ui/responsive/theme-blue/razer/js/combined.js'
}]
}
},
watch: {
css: {
files: ['**/*.scss', '**/*.css'],
tasks: ['sass', 'cssmin']
},
build: {
files: ['web/webroot/_ui/responsive/theme-blue/razer/js/*.js', 'web/webroot/_ui/responsive/common/js/*.js', 'web/webroot/_ui/responsive/theme-blue/razer/js/plugin/*.js'], // which files to watch
tasks: ['uglify:build'],
options: {
nospawn: true
}
},
debug: {
files: ['web/webroot/_ui/responsive/theme-blue/razer/js/*.js', 'web/webroot/_ui/responsive/common/js/*.js'], // which files to watch
tasks: ['uglify:debug'],
options: {
nospawn: true
}
}
}
});
// Plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
//grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.registerTask('build', ['watch']);
grunt.registerTask('default', ['sass', 'cssmin', 'uglify']);
grunt.registerTask('debug', ['uglify:debug', 'watch:debug']);
grunt.registerTask('lib', ['uglify:lib']);
};
```
|
2019/05/17
|
[
"https://Stackoverflow.com/questions/56188610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8550627/"
] |
In css `body` tag defines the document's whole body and the `div` is a part of it, there are two ways to get this working.
1. Make the `div` to cover the entire page and set the image to the `div`
Refer here:
[Making a div that covers the entire page](https://stackoverflow.com/questions/3250790/making-a-div-that-covers-the-entire-page)
Modified bit of code,
```
className='row',
style={
'verticalAlign':'middle',
'textAlign': 'center',
'background-image':image,
'position':'fixed',
'width':'100%',
'height':'100%',
'top':'0px',
'left':'0px',
'z-index':'1000'
},
```
2. Modify the `body` tag in the`external_stylesheet` to have the property `background-image`,
```
body {
'background-image' : url(url!d);
}
```
|
There are 2 ways to get this done:
Note: Is is a good practice to create a **folder 'assets'** in the program's **root** directory, and place your image inside it.
**Method-1:**
```
app.layout = html.Div([ ...fill your children here... ],
style={'background-image': 'url(/assets/image.jpg)',
'background-size': '100%',
'position': 'fixed',
'width': '100%',
'height': '100%'
})
```
**Method-2:**
```
app.layout = html.Div([ ...fill your children here... ],
style={'background-image': 'url(/assets/image.jpg)',
'background-size': '100%',
'width': '100vw',
'height': '100vh'
})
```
|
55,441,507 |
I wrote this model for my app
models.py
---------
```
from django.db import models
from accounts.models import FrontendUsers
from django.utils import timezone
# Create your models here.
class Jit(models.Model):
value = models.CharField(max_length = 100, blank = False)
author = models.ForeignKey(FrontendUsers, on_delete=models.CASCADE)
date = models.DateField(default=timezone.now() )
```
In views I have defined a function which will populate table of Jits with indormation taken from user.
views.py
--------
```
def new_post (request):
if request.method == 'POST':
value = request.POST.get('value')
if value != '' and value :
author_id = int(request.POST['user_id'])
jit = Jit.objects.create(value = value,author=author_id)
jit.save()
return redirect('feed')
else:
messages.error(request,'There was some problem writing your jit.')
return redirect('feed')
```
Error
-----
>
> Cannot assign "15": "Jit.author" must be a "FrontendUsers" instance.
>
>
>
In simple words I am trying to add author\_id to Jit's table so that both tables can be connected.
|
2019/03/31
|
[
"https://Stackoverflow.com/questions/55441507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7911552/"
] |
Use one of these ways, but second one is better as it doesn't fetch author from database:
```
author = FrontendUsers.objects.get(id=author_id)
jit = Jit.objects.create(value = value,author=author)
```
or
```
jit = Jit.objects.create(value = value,author_id=author_id)
```
|
You can use it like
`jit = Jit.objects.create(value = value,author_id=author_id)`
|
55,441,507 |
I wrote this model for my app
models.py
---------
```
from django.db import models
from accounts.models import FrontendUsers
from django.utils import timezone
# Create your models here.
class Jit(models.Model):
value = models.CharField(max_length = 100, blank = False)
author = models.ForeignKey(FrontendUsers, on_delete=models.CASCADE)
date = models.DateField(default=timezone.now() )
```
In views I have defined a function which will populate table of Jits with indormation taken from user.
views.py
--------
```
def new_post (request):
if request.method == 'POST':
value = request.POST.get('value')
if value != '' and value :
author_id = int(request.POST['user_id'])
jit = Jit.objects.create(value = value,author=author_id)
jit.save()
return redirect('feed')
else:
messages.error(request,'There was some problem writing your jit.')
return redirect('feed')
```
Error
-----
>
> Cannot assign "15": "Jit.author" must be a "FrontendUsers" instance.
>
>
>
In simple words I am trying to add author\_id to Jit's table so that both tables can be connected.
|
2019/03/31
|
[
"https://Stackoverflow.com/questions/55441507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7911552/"
] |
You can use it like
`jit = Jit.objects.create(value = value,author_id=author_id)`
|
Your are converting the user instace in ant int.
I think you should be using a form to achieve what you want. Try something like this, it works for me.
```
def new_post (request):
if request.method == 'POST':
if your_form.is_valid():
value = your_form.cleaned_data["value"]
if value:
result = your_form.save(commit=False)
user = Jit.objects.get(id=value)
result.author = user
result.save()
```
|
55,441,507 |
I wrote this model for my app
models.py
---------
```
from django.db import models
from accounts.models import FrontendUsers
from django.utils import timezone
# Create your models here.
class Jit(models.Model):
value = models.CharField(max_length = 100, blank = False)
author = models.ForeignKey(FrontendUsers, on_delete=models.CASCADE)
date = models.DateField(default=timezone.now() )
```
In views I have defined a function which will populate table of Jits with indormation taken from user.
views.py
--------
```
def new_post (request):
if request.method == 'POST':
value = request.POST.get('value')
if value != '' and value :
author_id = int(request.POST['user_id'])
jit = Jit.objects.create(value = value,author=author_id)
jit.save()
return redirect('feed')
else:
messages.error(request,'There was some problem writing your jit.')
return redirect('feed')
```
Error
-----
>
> Cannot assign "15": "Jit.author" must be a "FrontendUsers" instance.
>
>
>
In simple words I am trying to add author\_id to Jit's table so that both tables can be connected.
|
2019/03/31
|
[
"https://Stackoverflow.com/questions/55441507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7911552/"
] |
Use one of these ways, but second one is better as it doesn't fetch author from database:
```
author = FrontendUsers.objects.get(id=author_id)
jit = Jit.objects.create(value = value,author=author)
```
or
```
jit = Jit.objects.create(value = value,author_id=author_id)
```
|
Your are converting the user instace in ant int.
I think you should be using a form to achieve what you want. Try something like this, it works for me.
```
def new_post (request):
if request.method == 'POST':
if your_form.is_valid():
value = your_form.cleaned_data["value"]
if value:
result = your_form.save(commit=False)
user = Jit.objects.get(id=value)
result.author = user
result.save()
```
|
8,399,788 |
This is a really easy one that I thought would be easily found on google but I can't think of the terminology.
I'm using CS4 and AS3 with a few multi-line dynamic text boxes beneath one another. When I populate the top text box I would like it to automatically push down the other text boxes beneath it when the content flows on to extra lines.
At the moment it only wraps to the gap that is between each text box but then stops when reaching the text box beneath.
Is there a property to allow for this (I've worked in Silverlight and there was on controls there) that I can just set or will I have to manually implement this and call functionality to re-set all the controls y properties each time I change the text in the text box?
Thanks
|
2011/12/06
|
[
"https://Stackoverflow.com/questions/8399788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67258/"
] |
There are products called Hardware Security Modules (HSMs) designed to provide secure and reliable key storage. Most of them have software to interface with windows Crypto APIs, so that for example your RSACryptoServiceProvider will transparently use the HSM.
|
This issue is similar to Windows reminding you to [Backup your encryption key](http://windows.microsoft.com/en-US/windows-vista/Back-up-Encrypting-File-System-EFS-certificate)
In that article after exporting your key they suggest:
>
> Store the backup copy of your EFS certificate in a safe place.
>
>
>
What is a safe place? I'd consider these 2 safe:
1) On an external disk not connected to the network (a thumb drive)
2) A printed copy of the key, ie base64 of the key bytes. (this is going a bit far I reckon)
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
```
var agencies = [];
$(".agency_field").each(function(index) { agencies.push($(this).val()); });
```
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
You're creating a new array for each iteration. Try instead instantiating an array before the each call and adding to the array each iteration.
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
```
var arr = []; $(".agency_field").each(function(index) { arr.push($(this).val()); });
```
`arr` would contain what you want in the end.
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
Your code shd be slightly changed to:
```
var agencies = [];
$(".agency_field").each(function(index) {
agencies.push($(this).val());
});
```
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
You need to create an array initially and then add each value to that array:
```
var agencies = [];
$(".agency_field").each(function(index) { agencies.push($(this).val()) });
```
|
5,552,434 |
I have x number of input fields with class='agency\_field'. How can I create a JS array that contain the values of all fields with this class?
Using jQuery, this gives a syntax error:
>
> $(".agency\_field").each(function(index)
> { agencies[] = $(this).val(); });
>
>
>
|
2011/04/05
|
[
"https://Stackoverflow.com/questions/5552434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149664/"
] |
You can use [`.map`](http://api.jquery.com/map) instead, which is perhaps more suited to your purpose:
```
var values = $(".agency_field").map(function() {
return this.value;
}).get();
alert(values.join(","));
```
|
You're quite used to a language like php? ;)
In Javascript, you'd use array.push() for appending to an array; so
```
$(".agency_field").each(function(index) { agencies.push( $(this).val() ); });
```
|
17,213,806 |
I have a rather basic question. I have several values in a column that I would like to replace for a single one, for instance:
`a<-data.frame(T=LETTERS[5:20],V=rnorm(16,10,1))`
and I would like to change all "E", "S", "T" in T for "AB", so I tried
```
a[a$T==c("E","S","T")]<-"AB"
```
and it gives me several warnings, and ends up replacing all to "AB"
I think it has something to do with levels and level's labels but I was not able to replace only some of the values, I would have to re-label each. Sorry for the trouble, and thanks for any help!
|
2013/06/20
|
[
"https://Stackoverflow.com/questions/17213806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1817709/"
] |
You can use function `recode()` from library `car` to change values also for the factors.
```
library(car)
a$T<-recode(a$T,"c('E','S','T')='AB'")
```
If you need to replace different values with different other values then all statements can be written in one function call.
```
recode(a$T,"c('E','S','T')='AB';c('F','G','H')='CD'")
```
|
This would maintain your data structure (a factor like you guessed):
```
x <- levels(a$T)
levels(a$T) <- ifelse(x %in% c("E","S","T"), "AB", x)
```
or
```
levels(a$T)[levels(a$T) %in% c("E","S","T")] <- "AB"
```
---
**Edit**: if you have many such replacements, it is a little more complicated but not impossible:
```
from <- list(c("E","S","T"), c("J", "K", "L"))
to <- c("AB", "YZ")
find.in.list <- function(x, y) match(TRUE, sapply(y, `%in%`, x = x))
idx.in.list <- sapply(levels(a$T), find.in.list, from)
levels(a$T) <- ifelse(is.na(idx.in.list), levels(a$T), to[idx.in.list])
a$T
# [1] AB F G H I YZ YZ YZ M N O P Q R AB AB
# Levels: AB F G H I YZ M N O P Q R
```
|
17,213,806 |
I have a rather basic question. I have several values in a column that I would like to replace for a single one, for instance:
`a<-data.frame(T=LETTERS[5:20],V=rnorm(16,10,1))`
and I would like to change all "E", "S", "T" in T for "AB", so I tried
```
a[a$T==c("E","S","T")]<-"AB"
```
and it gives me several warnings, and ends up replacing all to "AB"
I think it has something to do with levels and level's labels but I was not able to replace only some of the values, I would have to re-label each. Sorry for the trouble, and thanks for any help!
|
2013/06/20
|
[
"https://Stackoverflow.com/questions/17213806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1817709/"
] |
This would maintain your data structure (a factor like you guessed):
```
x <- levels(a$T)
levels(a$T) <- ifelse(x %in% c("E","S","T"), "AB", x)
```
or
```
levels(a$T)[levels(a$T) %in% c("E","S","T")] <- "AB"
```
---
**Edit**: if you have many such replacements, it is a little more complicated but not impossible:
```
from <- list(c("E","S","T"), c("J", "K", "L"))
to <- c("AB", "YZ")
find.in.list <- function(x, y) match(TRUE, sapply(y, `%in%`, x = x))
idx.in.list <- sapply(levels(a$T), find.in.list, from)
levels(a$T) <- ifelse(is.na(idx.in.list), levels(a$T), to[idx.in.list])
a$T
# [1] AB F G H I YZ YZ YZ M N O P Q R AB AB
# Levels: AB F G H I YZ M N O P Q R
```
|
Do you really want factors there ???
If not (I think you do not) do `options(stringsAsFactors=FALSE)`
So it is much simpler than that... => `a[a$T %in% c("E","S","T"),"T"]<-"AB"`
|
17,213,806 |
I have a rather basic question. I have several values in a column that I would like to replace for a single one, for instance:
`a<-data.frame(T=LETTERS[5:20],V=rnorm(16,10,1))`
and I would like to change all "E", "S", "T" in T for "AB", so I tried
```
a[a$T==c("E","S","T")]<-"AB"
```
and it gives me several warnings, and ends up replacing all to "AB"
I think it has something to do with levels and level's labels but I was not able to replace only some of the values, I would have to re-label each. Sorry for the trouble, and thanks for any help!
|
2013/06/20
|
[
"https://Stackoverflow.com/questions/17213806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1817709/"
] |
You can use function `recode()` from library `car` to change values also for the factors.
```
library(car)
a$T<-recode(a$T,"c('E','S','T')='AB'")
```
If you need to replace different values with different other values then all statements can be written in one function call.
```
recode(a$T,"c('E','S','T')='AB';c('F','G','H')='CD'")
```
|
Do you really want factors there ???
If not (I think you do not) do `options(stringsAsFactors=FALSE)`
So it is much simpler than that... => `a[a$T %in% c("E","S","T"),"T"]<-"AB"`
|
54,710,709 |
Can some please help me with some code, I'm building a shopping list app. So I have an array of products, inside each product object there's a category name. what I want to do is display product under each category using ngFor, like category name fresh food under it everything with fresh food gets displayed so on. here is my array:
```
var products = [{
"id": "219",
"product_id": "198909",
"sku": "20148089",
"prod_name": "Chocolate Mousse 1L",
"vendor": "Woolworths",
"price": "45.09",
"status": "0",
"category": "Bakery & Desserts"
}, {
"id": "220",
"product_id": "199403",
"sku": "20008307",
"prod_name": "Medium Carrots 500g",
"vendor": "Woolworths",
"price": "10.99",
"status": "0",
"category": "Carrots & Beetroot"
}, {
"id": "221",
"product_id": "204759",
"sku": "6009207908908",
"prod_name": "Fresh Spicy Lentil & Vegetable Soup 600g",
"vendor": "Woolworths",
"price": "40.78",
"status": "0",
"category": "Fresh Food"
}, {
"id": "222",
"product_id": "199015",
"sku": "6009182131643",
"prod_name": "Bulk White Gouda Cheese 900g",
"vendor": "Woolworths",
"price": "126.45",
"status": "0",
"category": "Cheese"
}]
```
|
2019/02/15
|
[
"https://Stackoverflow.com/questions/54710709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11067534/"
] |
The following plug-ins don't offer exactly what you want, but may be helpful:
* The [**Launcher Extension**](https://github.com/pedrosans/launcher-extension) adds **two buttons** to the main toolbar: one to run the **corresponding JUnit test** of the Java class opened in the active editor and a second button (green heart) to run or debug the **launch configuration previously selected in the button pull-down menu**.
* The [**Eclipse Runner**](https://marketplace.eclipse.org/content/eclipse-runner) (which you found yourself) provides the ***Runner* view** (instead of main toolbar buttons) which displays **multiple launch configurations which can be grouped by categories**.
If you want to **write your own plug-in** for multiple buttons, the [source code of the Launcher Extension shows how to add buttons to the main toolbar](https://github.com/pedrosans/launcher-extension/blob/master/launcher-extension-plugin/plugin.xml#L47-L79). If you want to [add the buttons dynamically (e. g. when the server is running), this example project might be helpful](https://github.com/rage5474/de.ragedev.example.dynamictoolbar/).
|
It can be achieved by writing eclipse plugin project. Which internally provides Tools/buttons and add functionality on each button to perform certain actions. This would require some idea of Eclipse plugin development, with SWT, JFace.
Run your project as eclipse application to see/debug your changes. Once you are satisfied, then export you plugin project as deployable feature
[](https://i.stack.imgur.com/5uuBT.png)
Place exported jar into eclipse ->plugin folder. Launch eclipse again. This will show button you have developed in eclipse plugin project.
|
54,710,709 |
Can some please help me with some code, I'm building a shopping list app. So I have an array of products, inside each product object there's a category name. what I want to do is display product under each category using ngFor, like category name fresh food under it everything with fresh food gets displayed so on. here is my array:
```
var products = [{
"id": "219",
"product_id": "198909",
"sku": "20148089",
"prod_name": "Chocolate Mousse 1L",
"vendor": "Woolworths",
"price": "45.09",
"status": "0",
"category": "Bakery & Desserts"
}, {
"id": "220",
"product_id": "199403",
"sku": "20008307",
"prod_name": "Medium Carrots 500g",
"vendor": "Woolworths",
"price": "10.99",
"status": "0",
"category": "Carrots & Beetroot"
}, {
"id": "221",
"product_id": "204759",
"sku": "6009207908908",
"prod_name": "Fresh Spicy Lentil & Vegetable Soup 600g",
"vendor": "Woolworths",
"price": "40.78",
"status": "0",
"category": "Fresh Food"
}, {
"id": "222",
"product_id": "199015",
"sku": "6009182131643",
"prod_name": "Bulk White Gouda Cheese 900g",
"vendor": "Woolworths",
"price": "126.45",
"status": "0",
"category": "Cheese"
}]
```
|
2019/02/15
|
[
"https://Stackoverflow.com/questions/54710709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11067534/"
] |
As an alternative, Eclipse 4.22 (Dec. 2021) comes with:
>
> [Launch Configuration View](https://www.eclipse.org/eclipse/news/4.22/platform.php#launch-config-view)
> ------------------------------------------------------------------------------------------------------
>
>
> The new Launch Configuration View allows quick access to all your launch configurations without the need to enter the launch dialogs.
>
>
> [](https://i.stack.imgur.com/V3Drn.png)
>
>
> You can launch (run, debug, profile, etc.) as well as terminate and/or relaunch running configurations directly from the view.
>
>
>
The view also provides API which allows third party contributions to hook into the view and provide "`launchables`".
|
It can be achieved by writing eclipse plugin project. Which internally provides Tools/buttons and add functionality on each button to perform certain actions. This would require some idea of Eclipse plugin development, with SWT, JFace.
Run your project as eclipse application to see/debug your changes. Once you are satisfied, then export you plugin project as deployable feature
[](https://i.stack.imgur.com/5uuBT.png)
Place exported jar into eclipse ->plugin folder. Launch eclipse again. This will show button you have developed in eclipse plugin project.
|
54,710,709 |
Can some please help me with some code, I'm building a shopping list app. So I have an array of products, inside each product object there's a category name. what I want to do is display product under each category using ngFor, like category name fresh food under it everything with fresh food gets displayed so on. here is my array:
```
var products = [{
"id": "219",
"product_id": "198909",
"sku": "20148089",
"prod_name": "Chocolate Mousse 1L",
"vendor": "Woolworths",
"price": "45.09",
"status": "0",
"category": "Bakery & Desserts"
}, {
"id": "220",
"product_id": "199403",
"sku": "20008307",
"prod_name": "Medium Carrots 500g",
"vendor": "Woolworths",
"price": "10.99",
"status": "0",
"category": "Carrots & Beetroot"
}, {
"id": "221",
"product_id": "204759",
"sku": "6009207908908",
"prod_name": "Fresh Spicy Lentil & Vegetable Soup 600g",
"vendor": "Woolworths",
"price": "40.78",
"status": "0",
"category": "Fresh Food"
}, {
"id": "222",
"product_id": "199015",
"sku": "6009182131643",
"prod_name": "Bulk White Gouda Cheese 900g",
"vendor": "Woolworths",
"price": "126.45",
"status": "0",
"category": "Cheese"
}]
```
|
2019/02/15
|
[
"https://Stackoverflow.com/questions/54710709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11067534/"
] |
The following plug-ins don't offer exactly what you want, but may be helpful:
* The [**Launcher Extension**](https://github.com/pedrosans/launcher-extension) adds **two buttons** to the main toolbar: one to run the **corresponding JUnit test** of the Java class opened in the active editor and a second button (green heart) to run or debug the **launch configuration previously selected in the button pull-down menu**.
* The [**Eclipse Runner**](https://marketplace.eclipse.org/content/eclipse-runner) (which you found yourself) provides the ***Runner* view** (instead of main toolbar buttons) which displays **multiple launch configurations which can be grouped by categories**.
If you want to **write your own plug-in** for multiple buttons, the [source code of the Launcher Extension shows how to add buttons to the main toolbar](https://github.com/pedrosans/launcher-extension/blob/master/launcher-extension-plugin/plugin.xml#L47-L79). If you want to [add the buttons dynamically (e. g. when the server is running), this example project might be helpful](https://github.com/rage5474/de.ragedev.example.dynamictoolbar/).
|
As an alternative, Eclipse 4.22 (Dec. 2021) comes with:
>
> [Launch Configuration View](https://www.eclipse.org/eclipse/news/4.22/platform.php#launch-config-view)
> ------------------------------------------------------------------------------------------------------
>
>
> The new Launch Configuration View allows quick access to all your launch configurations without the need to enter the launch dialogs.
>
>
> [](https://i.stack.imgur.com/V3Drn.png)
>
>
> You can launch (run, debug, profile, etc.) as well as terminate and/or relaunch running configurations directly from the view.
>
>
>
The view also provides API which allows third party contributions to hook into the view and provide "`launchables`".
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
Silestone is natural quartz aggregate, held together by a polymer binder. I believe it's something like 85% quartz. You'll need a diamond coated bit like **[this one](http://www.lowes.com/pd_146373-67702-728020_0__?productId=1017877&Ntt=diamond+drill&pl=1¤tURL=/pl__0__s%3FNtt%3Ddiamond%2Bdrill)**; it's a tiny hole saw where the rim is covered in diamonds:

It's a bit tricky to start, you need to hold the drill at a slight angle so that only one side of the circumference is grinding, and then as you start to develop a crescent-shaped groove you gradually move your drill perpendicular and continue with the rest of the hole. If you don't do this the thing will walk all over the place since it has no positive center like a regular hole saw.
For drilling upside down you'll want a spray bottle with water to keep the surface as wet as possible. That Hitachi bit I linked to has a spiral groove going in the opposite direction of a normal drill bit, which serves to draw water *into* the hole, which will help you when drilling upside down.
Obviously you want to be careful not to drill too far and pop out of the top of your nice counters.
For fastening the dishwasher you'll need a plastic anchor into which to run your screws, and I've found **[this type](http://www.toggler.com/products/alligator/overview.php)** works great. In a solid material the plastic will extrude around the screw threads and hold really tightly. They do sell them at my Lowe's but I can't find them on their website. The 3/16" size is probably what you need for your dishwasher, and the diamond bit I linked to above is also 3/16". Good luck!
|
I used a bit from Menards store like a Home Depot or Lowes. I cut a 1 3/8 hole in Cambria quartz for a faucet. The Brand was Montana MB-65208 diamond tipped bit. I cut at an angle to start then cut straight through by using the pumping motion, Applying water every few seconds. I did a practice and a real cut no problems. Good Luck all.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
I had a similar situation and solved it by gluing a strip of wood with the same finish as the cabinets underneath the counter top and securing the dishwasher to it instead. If you have the room underneath your counters for it, this might be something to consider. IIRC, the piece I used was 3/8" high by 1" deep and ran the width of the opening.
If you don't have the room, or just want to screw the dishwasher directly to the counter top, this article on [How to Drill Holes in Silestone](http://www.ehow.com/how_5968501_drill-holes-silestone.html) suggests using a diamond-tipped drill bit and a pool of water for lubrication and cooling. Since you'll be drilling on the underside, the lubrication method they describe won't work; I'd suggest drilling in very short bursts, allowing the area to cool between bursts.
|
I used a bit from Menards store like a Home Depot or Lowes. I cut a 1 3/8 hole in Cambria quartz for a faucet. The Brand was Montana MB-65208 diamond tipped bit. I cut at an angle to start then cut straight through by using the pumping motion, Applying water every few seconds. I did a practice and a real cut no problems. Good Luck all.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
With my granite counter top there are steel plates which have been epoxied to the underside of the granite counter. The dishwasher clips then are bolted into these. When my granite counter top was installed the installers left the plates and the epoxy (since the dishwasher was not there yet) but I am sure you can find the same thing at a hardware store.
The other thing to look into is side mounting the dishwasher (I actually have one of the top bolts in use and the other side of my dishwasher is side mounted. This worked the best when I was putting in the dishwasher and allowed me to get it secured with very little movement when it is opened and closed).
Also, just noticed these "[Granite Grabbers](http://rads.stackoverflow.com/amzn/click/B002UQ107O)" on Amazon. I have not used them but they might be worth a try.

|
I used a bit from Menards store like a Home Depot or Lowes. I cut a 1 3/8 hole in Cambria quartz for a faucet. The Brand was Montana MB-65208 diamond tipped bit. I cut at an angle to start then cut straight through by using the pumping motion, Applying water every few seconds. I did a practice and a real cut no problems. Good Luck all.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
Silestone is natural quartz aggregate, held together by a polymer binder. I believe it's something like 85% quartz. You'll need a diamond coated bit like **[this one](http://www.lowes.com/pd_146373-67702-728020_0__?productId=1017877&Ntt=diamond+drill&pl=1¤tURL=/pl__0__s%3FNtt%3Ddiamond%2Bdrill)**; it's a tiny hole saw where the rim is covered in diamonds:

It's a bit tricky to start, you need to hold the drill at a slight angle so that only one side of the circumference is grinding, and then as you start to develop a crescent-shaped groove you gradually move your drill perpendicular and continue with the rest of the hole. If you don't do this the thing will walk all over the place since it has no positive center like a regular hole saw.
For drilling upside down you'll want a spray bottle with water to keep the surface as wet as possible. That Hitachi bit I linked to has a spiral groove going in the opposite direction of a normal drill bit, which serves to draw water *into* the hole, which will help you when drilling upside down.
Obviously you want to be careful not to drill too far and pop out of the top of your nice counters.
For fastening the dishwasher you'll need a plastic anchor into which to run your screws, and I've found **[this type](http://www.toggler.com/products/alligator/overview.php)** works great. In a solid material the plastic will extrude around the screw threads and hold really tightly. They do sell them at my Lowe's but I can't find them on their website. The 3/16" size is probably what you need for your dishwasher, and the diamond bit I linked to above is also 3/16". Good luck!
|
Is your dishwasher configured so that you can attach it to the sides of the cabinets instead? This method would only require a normal wood drill bit for a pilot hole. You may want to put some tape or a depth stop collar around the bit so that you don't drill all the way through the cabinet walls though.
An employee at a local kitchen store told me that I should consider using the same clips to side mount the dishwasher to the cabinet using the above method instead of the underside of the counter top. I then looked in the installation manual for my model of dishwasher and sure enough, it's shown right there in black and white.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
I had a similar situation and solved it by gluing a strip of wood with the same finish as the cabinets underneath the counter top and securing the dishwasher to it instead. If you have the room underneath your counters for it, this might be something to consider. IIRC, the piece I used was 3/8" high by 1" deep and ran the width of the opening.
If you don't have the room, or just want to screw the dishwasher directly to the counter top, this article on [How to Drill Holes in Silestone](http://www.ehow.com/how_5968501_drill-holes-silestone.html) suggests using a diamond-tipped drill bit and a pool of water for lubrication and cooling. Since you'll be drilling on the underside, the lubrication method they describe won't work; I'd suggest drilling in very short bursts, allowing the area to cool between bursts.
|
With my granite counter top there are steel plates which have been epoxied to the underside of the granite counter. The dishwasher clips then are bolted into these. When my granite counter top was installed the installers left the plates and the epoxy (since the dishwasher was not there yet) but I am sure you can find the same thing at a hardware store.
The other thing to look into is side mounting the dishwasher (I actually have one of the top bolts in use and the other side of my dishwasher is side mounted. This worked the best when I was putting in the dishwasher and allowed me to get it secured with very little movement when it is opened and closed).
Also, just noticed these "[Granite Grabbers](http://rads.stackoverflow.com/amzn/click/B002UQ107O)" on Amazon. I have not used them but they might be worth a try.

|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
I had a similar situation and solved it by gluing a strip of wood with the same finish as the cabinets underneath the counter top and securing the dishwasher to it instead. If you have the room underneath your counters for it, this might be something to consider. IIRC, the piece I used was 3/8" high by 1" deep and ran the width of the opening.
If you don't have the room, or just want to screw the dishwasher directly to the counter top, this article on [How to Drill Holes in Silestone](http://www.ehow.com/how_5968501_drill-holes-silestone.html) suggests using a diamond-tipped drill bit and a pool of water for lubrication and cooling. Since you'll be drilling on the underside, the lubrication method they describe won't work; I'd suggest drilling in very short bursts, allowing the area to cool between bursts.
|
If you have trouble getting hold of a diamond tip drill, or simply find that far too expensive, you should be able to use a regular glass drill bit for the job. Two precautions are required:
1. Don't drill at too high a speed
2. Keep the it cool
The simplest way to achieve cooling for the bit is to create a circle of putty around he spot to be drilled and fill it with turpentine.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
I had a similar situation and solved it by gluing a strip of wood with the same finish as the cabinets underneath the counter top and securing the dishwasher to it instead. If you have the room underneath your counters for it, this might be something to consider. IIRC, the piece I used was 3/8" high by 1" deep and ran the width of the opening.
If you don't have the room, or just want to screw the dishwasher directly to the counter top, this article on [How to Drill Holes in Silestone](http://www.ehow.com/how_5968501_drill-holes-silestone.html) suggests using a diamond-tipped drill bit and a pool of water for lubrication and cooling. Since you'll be drilling on the underside, the lubrication method they describe won't work; I'd suggest drilling in very short bursts, allowing the area to cool between bursts.
|
Is your dishwasher configured so that you can attach it to the sides of the cabinets instead? This method would only require a normal wood drill bit for a pilot hole. You may want to put some tape or a depth stop collar around the bit so that you don't drill all the way through the cabinet walls though.
An employee at a local kitchen store told me that I should consider using the same clips to side mount the dishwasher to the cabinet using the above method instead of the underside of the counter top. I then looked in the installation manual for my model of dishwasher and sure enough, it's shown right there in black and white.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
Silestone is natural quartz aggregate, held together by a polymer binder. I believe it's something like 85% quartz. You'll need a diamond coated bit like **[this one](http://www.lowes.com/pd_146373-67702-728020_0__?productId=1017877&Ntt=diamond+drill&pl=1¤tURL=/pl__0__s%3FNtt%3Ddiamond%2Bdrill)**; it's a tiny hole saw where the rim is covered in diamonds:

It's a bit tricky to start, you need to hold the drill at a slight angle so that only one side of the circumference is grinding, and then as you start to develop a crescent-shaped groove you gradually move your drill perpendicular and continue with the rest of the hole. If you don't do this the thing will walk all over the place since it has no positive center like a regular hole saw.
For drilling upside down you'll want a spray bottle with water to keep the surface as wet as possible. That Hitachi bit I linked to has a spiral groove going in the opposite direction of a normal drill bit, which serves to draw water *into* the hole, which will help you when drilling upside down.
Obviously you want to be careful not to drill too far and pop out of the top of your nice counters.
For fastening the dishwasher you'll need a plastic anchor into which to run your screws, and I've found **[this type](http://www.toggler.com/products/alligator/overview.php)** works great. In a solid material the plastic will extrude around the screw threads and hold really tightly. They do sell them at my Lowe's but I can't find them on their website. The 3/16" size is probably what you need for your dishwasher, and the diamond bit I linked to above is also 3/16". Good luck!
|
With my granite counter top there are steel plates which have been epoxied to the underside of the granite counter. The dishwasher clips then are bolted into these. When my granite counter top was installed the installers left the plates and the epoxy (since the dishwasher was not there yet) but I am sure you can find the same thing at a hardware store.
The other thing to look into is side mounting the dishwasher (I actually have one of the top bolts in use and the other side of my dishwasher is side mounted. This worked the best when I was putting in the dishwasher and allowed me to get it secured with very little movement when it is opened and closed).
Also, just noticed these "[Granite Grabbers](http://rads.stackoverflow.com/amzn/click/B002UQ107O)" on Amazon. I have not used them but they might be worth a try.

|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
Silestone is natural quartz aggregate, held together by a polymer binder. I believe it's something like 85% quartz. You'll need a diamond coated bit like **[this one](http://www.lowes.com/pd_146373-67702-728020_0__?productId=1017877&Ntt=diamond+drill&pl=1¤tURL=/pl__0__s%3FNtt%3Ddiamond%2Bdrill)**; it's a tiny hole saw where the rim is covered in diamonds:

It's a bit tricky to start, you need to hold the drill at a slight angle so that only one side of the circumference is grinding, and then as you start to develop a crescent-shaped groove you gradually move your drill perpendicular and continue with the rest of the hole. If you don't do this the thing will walk all over the place since it has no positive center like a regular hole saw.
For drilling upside down you'll want a spray bottle with water to keep the surface as wet as possible. That Hitachi bit I linked to has a spiral groove going in the opposite direction of a normal drill bit, which serves to draw water *into* the hole, which will help you when drilling upside down.
Obviously you want to be careful not to drill too far and pop out of the top of your nice counters.
For fastening the dishwasher you'll need a plastic anchor into which to run your screws, and I've found **[this type](http://www.toggler.com/products/alligator/overview.php)** works great. In a solid material the plastic will extrude around the screw threads and hold really tightly. They do sell them at my Lowe's but I can't find them on their website. The 3/16" size is probably what you need for your dishwasher, and the diamond bit I linked to above is also 3/16". Good luck!
|
I had a similar situation and solved it by gluing a strip of wood with the same finish as the cabinets underneath the counter top and securing the dishwasher to it instead. If you have the room underneath your counters for it, this might be something to consider. IIRC, the piece I used was 3/8" high by 1" deep and ran the width of the opening.
If you don't have the room, or just want to screw the dishwasher directly to the counter top, this article on [How to Drill Holes in Silestone](http://www.ehow.com/how_5968501_drill-holes-silestone.html) suggests using a diamond-tipped drill bit and a pool of water for lubrication and cooling. Since you'll be drilling on the underside, the lubrication method they describe won't work; I'd suggest drilling in very short bursts, allowing the area to cool between bursts.
|
3,469 |
I need to drill 2 small holes on the underside of my Silestone countertop to secure a new dishwasher. What kind of drill bit can I use?
AFAIK Silestone is some kind of artificial quartz, but I wonder if it's too hard for normal masonry bit.
|
2010/12/13
|
[
"https://diy.stackexchange.com/questions/3469",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/1313/"
] |
With my granite counter top there are steel plates which have been epoxied to the underside of the granite counter. The dishwasher clips then are bolted into these. When my granite counter top was installed the installers left the plates and the epoxy (since the dishwasher was not there yet) but I am sure you can find the same thing at a hardware store.
The other thing to look into is side mounting the dishwasher (I actually have one of the top bolts in use and the other side of my dishwasher is side mounted. This worked the best when I was putting in the dishwasher and allowed me to get it secured with very little movement when it is opened and closed).
Also, just noticed these "[Granite Grabbers](http://rads.stackoverflow.com/amzn/click/B002UQ107O)" on Amazon. I have not used them but they might be worth a try.

|
If you have trouble getting hold of a diamond tip drill, or simply find that far too expensive, you should be able to use a regular glass drill bit for the job. Two precautions are required:
1. Don't drill at too high a speed
2. Keep the it cool
The simplest way to achieve cooling for the bit is to create a circle of putty around he spot to be drilled and fill it with turpentine.
|
157,125 |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I have this weird question, for example if I have a `.cpp` file in which I am using 1000 different functions, and each of those functions has its own separate `.cpp` and `.h` file, how does the linker know which of the cpp files to scan to find that specific function? I mean does the linker know where the function is located or does the linker every time for every function scan the whole project to find that specific function?
|
2023/01/27
|
[
"https://cs.stackexchange.com/questions/157125",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/157168/"
] |
The compiler compiles from a .cpp file to an object file (.o) with the binary code.
The linker combines all of the object files together into a single binary.
So, the linker doesn't need to know which cpp to look at, because the linker doesn't look at cpp files. Instead, the linker looks at all of the .o files, figures out where all the functions are, and combines them together.
|
>
> It is the linker's job to link the function declaration to its implementation
>
>
>
This is not true. This is the compiler's job. Essentially the declaration (I'm assuming you mean the prototype, as in `return_type function_name (arguments...)`) is part of the language to allow you to tell the compiler what the function looks like before the compiler finds its implementation (the code body between `{` and `}`).
A lot of functions in fact are declared at the same place they are implemented. However it is also common to declare function prototypes without an implementation in headers or in virtual classes. This basically tells the compiler "hey, this is what the function looks like, but you will find the implementation later or somewhere else".
By the time you run the linker it is no longer processing things like declarations. Instead, linkers deal only with compiled code and some of that code consists of functions.
The final binary code does not actually contain any function definitions. Instead, code is simply a long list of machine instructions. A function is simply an address to somewhere in the code. For example a function like `add()` may be located at the 12566th byte of the binary code (or 0x00003116 in hex which is a more common way to look at addresses). The code that calls that function will simply be the instruction `call 0x00003116`. At this stage there is no information that that location contains a function.
However linkers work with object (or library) files that contain metadata, not just pure binary code. The actual format of these files depend on a lot of things - the language you use, the operating system you are on, the type of file etc. (for example, obj files in C/C++, lib files on Linux, dll files on Windows, etc.). However, what these files must contain is a list of what is sometimes called "symbols" and what addresses those symbols point to. These symbols are basically the function signature which tells the linker things like what the function's name is in the source code, how many arguments the function accepts, etc. This list of symbols is usually called the symbol table.
Actually, during compilation the compiler keeps a data structure called the symbol table in RAM in order to remember what it has compiled. Once the code is compiled, the compiler will format this symbol table appropriately and insert it in the object or library file.
When the linker sees that some code is calling `add()` it scans the list of files it is working on (or it looks up the database/array that it stored all the scanned files) and checks their symbol table to find `add()`. Once found, it will replace the caller's symbol with the address of the `add()` function (eg, 0x00003116). There is another step called the fixup which recalculates the address in RAM depending on how the executable or library file is loaded into RAM but I'll leave the details of that process as further research. It's enough to know that the linker's job is to load all the files you pass to it, remember all their symbol tables, and then replace symbols in code with actual addresses in memory.
|
157,125 |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I have this weird question, for example if I have a `.cpp` file in which I am using 1000 different functions, and each of those functions has its own separate `.cpp` and `.h` file, how does the linker know which of the cpp files to scan to find that specific function? I mean does the linker know where the function is located or does the linker every time for every function scan the whole project to find that specific function?
|
2023/01/27
|
[
"https://cs.stackexchange.com/questions/157125",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/157168/"
] |
The compiler compiles from a .cpp file to an object file (.o) with the binary code.
The linker combines all of the object files together into a single binary.
So, the linker doesn't need to know which cpp to look at, because the linker doesn't look at cpp files. Instead, the linker looks at all of the .o files, figures out where all the functions are, and combines them together.
|
For C and C++, the linker's job is the same, ignoring template classes/functions.
The .o / .obj files are split into Sections, each of which has a Symbol Table.
The Symbol Table has the offset into this Section of each exported Symbol (function, global variable), and a set of relations. These are the function calls, and references to global variables. The linker will determine which Object file contains \_main, and add it to the .exe it is building. It will then scan the relocations for the Section, and determine that \_add is being used. It then finds the .obj file that provides \_add, and adds it to the .exe. It then patches the Section that has \_main at the offset given in the Relocation Table, and writes the Absolute or Relative address of \_add here. It then locates all the Symbols that the Section that \_add requires, and processes them in the same way.
A .a / .lib file is a collection of Object files, optionally with an Index that lists all the Symbols the Library contains, for MS Visual Studio, this Index file is processed once, and the object files are added to the .exe as needed.
UNIX traditionally only scans Library files when needed, and if a Library needs another Library, then this must be listed before the requiring Library.
A worked example may be helpful.
Assuming that the linker is looking for \_main, and it finds it in foo.obj, at offset 100 in the .DATA Section.
This Section is added to the .DATA Section of the .exe, and the caller is updated to have the address of \_main. A C or C++ program does not start at \_main - there is a function the initialises the C run time, any global variables, and then calls \_main. In MSVC command-line programs this is \_mainCRTStartup, but will have other names for other compilers.
The linker then finds \_add in bar.c in Section .DATA, and adds it to the .DATA section.
Assume that foo.c .DATA Section was 500 bytes longs, this means that bar.c .DATA section is now at 500 bytes in. \_add is 200 bytes into bar.obj .DATA setion, so \_add is 700 bytes into the .exe .DATA section. Thus 700 is written into the .exe .DATA section at location 100 - which is where \_add is called. The process repeats until all Relocations have had their Sections added to the .exec.
|
157,125 |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I have this weird question, for example if I have a `.cpp` file in which I am using 1000 different functions, and each of those functions has its own separate `.cpp` and `.h` file, how does the linker know which of the cpp files to scan to find that specific function? I mean does the linker know where the function is located or does the linker every time for every function scan the whole project to find that specific function?
|
2023/01/27
|
[
"https://cs.stackexchange.com/questions/157125",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/157168/"
] |
The linker is given explicitly the list of files to use, in the command line of the linker. They can be object files (.obj / .o) - compiled code - or libraries (.lib / .a) - object files structured in a single one.
Part of the job of the linker is to establish a list of the available functions and assign them an address in memory. This is enough to generate the calls where needed.
Note that the linker does not see the source code itself.
|
>
> It is the linker's job to link the function declaration to its implementation
>
>
>
This is not true. This is the compiler's job. Essentially the declaration (I'm assuming you mean the prototype, as in `return_type function_name (arguments...)`) is part of the language to allow you to tell the compiler what the function looks like before the compiler finds its implementation (the code body between `{` and `}`).
A lot of functions in fact are declared at the same place they are implemented. However it is also common to declare function prototypes without an implementation in headers or in virtual classes. This basically tells the compiler "hey, this is what the function looks like, but you will find the implementation later or somewhere else".
By the time you run the linker it is no longer processing things like declarations. Instead, linkers deal only with compiled code and some of that code consists of functions.
The final binary code does not actually contain any function definitions. Instead, code is simply a long list of machine instructions. A function is simply an address to somewhere in the code. For example a function like `add()` may be located at the 12566th byte of the binary code (or 0x00003116 in hex which is a more common way to look at addresses). The code that calls that function will simply be the instruction `call 0x00003116`. At this stage there is no information that that location contains a function.
However linkers work with object (or library) files that contain metadata, not just pure binary code. The actual format of these files depend on a lot of things - the language you use, the operating system you are on, the type of file etc. (for example, obj files in C/C++, lib files on Linux, dll files on Windows, etc.). However, what these files must contain is a list of what is sometimes called "symbols" and what addresses those symbols point to. These symbols are basically the function signature which tells the linker things like what the function's name is in the source code, how many arguments the function accepts, etc. This list of symbols is usually called the symbol table.
Actually, during compilation the compiler keeps a data structure called the symbol table in RAM in order to remember what it has compiled. Once the code is compiled, the compiler will format this symbol table appropriately and insert it in the object or library file.
When the linker sees that some code is calling `add()` it scans the list of files it is working on (or it looks up the database/array that it stored all the scanned files) and checks their symbol table to find `add()`. Once found, it will replace the caller's symbol with the address of the `add()` function (eg, 0x00003116). There is another step called the fixup which recalculates the address in RAM depending on how the executable or library file is loaded into RAM but I'll leave the details of that process as further research. It's enough to know that the linker's job is to load all the files you pass to it, remember all their symbol tables, and then replace symbols in code with actual addresses in memory.
|
157,125 |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I have this weird question, for example if I have a `.cpp` file in which I am using 1000 different functions, and each of those functions has its own separate `.cpp` and `.h` file, how does the linker know which of the cpp files to scan to find that specific function? I mean does the linker know where the function is located or does the linker every time for every function scan the whole project to find that specific function?
|
2023/01/27
|
[
"https://cs.stackexchange.com/questions/157125",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/157168/"
] |
The linker is given explicitly the list of files to use, in the command line of the linker. They can be object files (.obj / .o) - compiled code - or libraries (.lib / .a) - object files structured in a single one.
Part of the job of the linker is to establish a list of the available functions and assign them an address in memory. This is enough to generate the calls where needed.
Note that the linker does not see the source code itself.
|
For C and C++, the linker's job is the same, ignoring template classes/functions.
The .o / .obj files are split into Sections, each of which has a Symbol Table.
The Symbol Table has the offset into this Section of each exported Symbol (function, global variable), and a set of relations. These are the function calls, and references to global variables. The linker will determine which Object file contains \_main, and add it to the .exe it is building. It will then scan the relocations for the Section, and determine that \_add is being used. It then finds the .obj file that provides \_add, and adds it to the .exe. It then patches the Section that has \_main at the offset given in the Relocation Table, and writes the Absolute or Relative address of \_add here. It then locates all the Symbols that the Section that \_add requires, and processes them in the same way.
A .a / .lib file is a collection of Object files, optionally with an Index that lists all the Symbols the Library contains, for MS Visual Studio, this Index file is processed once, and the object files are added to the .exe as needed.
UNIX traditionally only scans Library files when needed, and if a Library needs another Library, then this must be listed before the requiring Library.
A worked example may be helpful.
Assuming that the linker is looking for \_main, and it finds it in foo.obj, at offset 100 in the .DATA Section.
This Section is added to the .DATA Section of the .exe, and the caller is updated to have the address of \_main. A C or C++ program does not start at \_main - there is a function the initialises the C run time, any global variables, and then calls \_main. In MSVC command-line programs this is \_mainCRTStartup, but will have other names for other compilers.
The linker then finds \_add in bar.c in Section .DATA, and adds it to the .DATA section.
Assume that foo.c .DATA Section was 500 bytes longs, this means that bar.c .DATA section is now at 500 bytes in. \_add is 200 bytes into bar.obj .DATA setion, so \_add is 700 bytes into the .exe .DATA section. Thus 700 is written into the .exe .DATA section at location 100 - which is where \_add is called. The process repeats until all Relocations have had their Sections added to the .exec.
|
157,125 |
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation.
But now I have this weird question, for example if I have a `.cpp` file in which I am using 1000 different functions, and each of those functions has its own separate `.cpp` and `.h` file, how does the linker know which of the cpp files to scan to find that specific function? I mean does the linker know where the function is located or does the linker every time for every function scan the whole project to find that specific function?
|
2023/01/27
|
[
"https://cs.stackexchange.com/questions/157125",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/157168/"
] |
>
> It is the linker's job to link the function declaration to its implementation
>
>
>
This is not true. This is the compiler's job. Essentially the declaration (I'm assuming you mean the prototype, as in `return_type function_name (arguments...)`) is part of the language to allow you to tell the compiler what the function looks like before the compiler finds its implementation (the code body between `{` and `}`).
A lot of functions in fact are declared at the same place they are implemented. However it is also common to declare function prototypes without an implementation in headers or in virtual classes. This basically tells the compiler "hey, this is what the function looks like, but you will find the implementation later or somewhere else".
By the time you run the linker it is no longer processing things like declarations. Instead, linkers deal only with compiled code and some of that code consists of functions.
The final binary code does not actually contain any function definitions. Instead, code is simply a long list of machine instructions. A function is simply an address to somewhere in the code. For example a function like `add()` may be located at the 12566th byte of the binary code (or 0x00003116 in hex which is a more common way to look at addresses). The code that calls that function will simply be the instruction `call 0x00003116`. At this stage there is no information that that location contains a function.
However linkers work with object (or library) files that contain metadata, not just pure binary code. The actual format of these files depend on a lot of things - the language you use, the operating system you are on, the type of file etc. (for example, obj files in C/C++, lib files on Linux, dll files on Windows, etc.). However, what these files must contain is a list of what is sometimes called "symbols" and what addresses those symbols point to. These symbols are basically the function signature which tells the linker things like what the function's name is in the source code, how many arguments the function accepts, etc. This list of symbols is usually called the symbol table.
Actually, during compilation the compiler keeps a data structure called the symbol table in RAM in order to remember what it has compiled. Once the code is compiled, the compiler will format this symbol table appropriately and insert it in the object or library file.
When the linker sees that some code is calling `add()` it scans the list of files it is working on (or it looks up the database/array that it stored all the scanned files) and checks their symbol table to find `add()`. Once found, it will replace the caller's symbol with the address of the `add()` function (eg, 0x00003116). There is another step called the fixup which recalculates the address in RAM depending on how the executable or library file is loaded into RAM but I'll leave the details of that process as further research. It's enough to know that the linker's job is to load all the files you pass to it, remember all their symbol tables, and then replace symbols in code with actual addresses in memory.
|
For C and C++, the linker's job is the same, ignoring template classes/functions.
The .o / .obj files are split into Sections, each of which has a Symbol Table.
The Symbol Table has the offset into this Section of each exported Symbol (function, global variable), and a set of relations. These are the function calls, and references to global variables. The linker will determine which Object file contains \_main, and add it to the .exe it is building. It will then scan the relocations for the Section, and determine that \_add is being used. It then finds the .obj file that provides \_add, and adds it to the .exe. It then patches the Section that has \_main at the offset given in the Relocation Table, and writes the Absolute or Relative address of \_add here. It then locates all the Symbols that the Section that \_add requires, and processes them in the same way.
A .a / .lib file is a collection of Object files, optionally with an Index that lists all the Symbols the Library contains, for MS Visual Studio, this Index file is processed once, and the object files are added to the .exe as needed.
UNIX traditionally only scans Library files when needed, and if a Library needs another Library, then this must be listed before the requiring Library.
A worked example may be helpful.
Assuming that the linker is looking for \_main, and it finds it in foo.obj, at offset 100 in the .DATA Section.
This Section is added to the .DATA Section of the .exe, and the caller is updated to have the address of \_main. A C or C++ program does not start at \_main - there is a function the initialises the C run time, any global variables, and then calls \_main. In MSVC command-line programs this is \_mainCRTStartup, but will have other names for other compilers.
The linker then finds \_add in bar.c in Section .DATA, and adds it to the .DATA section.
Assume that foo.c .DATA Section was 500 bytes longs, this means that bar.c .DATA section is now at 500 bytes in. \_add is 200 bytes into bar.obj .DATA setion, so \_add is 700 bytes into the .exe .DATA section. Thus 700 is written into the .exe .DATA section at location 100 - which is where \_add is called. The process repeats until all Relocations have had their Sections added to the .exec.
|
12,159,915 |
My scene consists of a plane which I'm shading with two textures. The first, bottom-most, texture is a solid image coming from the camera of the iPhone, the second image is a kind of viewfinder which I need to overlay over the camera input (with transparency). I'm getting these black dark lines at the borders of solids in my transparent texture.

I've been doing some research on this and came to the understanding that this artifact is a result of interpolation combined with premultiplied alpha. Since XCode converts all PNG images automatically to premultiplied pngs and the code I wrote to load the image is also respecting a premultiplied alpha context I'm kinda stuck on where the exact problem is located.
I've tried the following solutions:
* made sure that pixels with an alpha value of 0 had their rgb values also set to 0
* turned off xcode's automatic png compression so that it leaves the texture as provided by me
* fiddled around with the fragment shader to avoid the mix() call
* changed the AlphaInfo value when creating the bitmap context
Important: I'm not using glBlendFunc(), I'm feeding the two textures together to 1 fragment shader and try to mix them in there. So a solution through this gl-call won't get me any further.
Here's the code I'm using for loading the transparent texture:
```
shared_ptr<ImageData> IOSFileSystem::loadImageFile(string path, bool flip) const
{
cout << path << endl;
// Result
shared_ptr<ImageData> result = shared_ptr<ImageData>();
// Convert cpp string to nsstring
NSString *convertedPathString = [NSString stringWithCString:path.c_str() encoding:[NSString defaultCStringEncoding]];
NSString *fullPath = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], convertedPathString];
// Check if file exists
if([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:NO])
{
// Load image
UIImage *image = [[[UIImage alloc] initWithContentsOfFile:fullPath] autorelease];
CGImageRef imageRef = image.CGImage;
// Allocate memory for the image
size_t width = CGImageGetWidth(imageRef);
size_t height = CGImageGetHeight(imageRef);
GLubyte *spriteData = (GLubyte*) calloc(width * height * 4, sizeof(GLubyte));
// Create drawing context
CGContextRef context = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(imageRef), kCGImageAlphaPremultipliedLast);
// Flip for OpenGL coord system
if(flip)
{
CGContextTranslateCTM(context, 0, image.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
}
// Draw & release
CGContextDrawImage(context, CGRectMake(0.0, 0.0, width, height), imageRef);
CGContextRelease(context);
// Put result in shared ptr
// Don't free() the spritedata because our shared pointer will take care of that
// Since the shared pointer doesn't know how to free "calloc" data, we have to teach it how: &std::free
shared_ptr<GLubyte> spriteDataPtr = shared_ptr<GLubyte>(spriteData, &std::free);
result = shared_ptr<ImageData>(new ImageData(path, width, height, spriteDataPtr));
}
else
{
cout << "IOSFileSystem::loadImageFile -> File does not exist at path.\nPath: " + path;
exit(1);
}
return result;
}
```
Here's how I set the pixels on the texture:
```
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
```
Here's a stripped down version of the fragment shader:
```
void main(void)
{
lowp vec4 camera = texture2D(texture0, destinationTexCoord);
lowp vec4 viewfinder = texture2D(texture1, destinationTexCoord);
lowp vec4 result = mix(camera, viewfinder, viewfinder.a);
gl_FragColor = result;
}
```
|
2012/08/28
|
[
"https://Stackoverflow.com/questions/12159915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341358/"
] |
This may be because of `premultiplied alpha` in PNG images. Try to modify blending mode:
```
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // instead of (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
```
|
I found the solution to my problem by investigating how the `glBlendFunc` call works. I used [this editor](http://www.andersriggelsen.dk/glblendfunc.php) to check what formula is used to blend with `GL_ONE` and `GL_ONE_MINUS_SRC_ALPHA`.
This led to the following fragment shader code:
```
lowp vec4 camera = texture2D(texture0, destinationTexCoord);
lowp vec4 viewfinder = texture2D(texture1, destinationTexCoord);
lowp vec4 result = viewfinder + camera * vec4(1.0 - viewfinder.a);
```
|
39,675,764 |
I have a table called Student, the student table contains the id, first\_name and last\_name. I am trying to select and concatenate first\_name and last\_name and display the column as "Name". This is my query:
```
Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204)
```
but it returns
```
SELECT concat(first_name, ' ', last_name) as 'Name' FROM `students` WHERE `students`.`id` = 201410204 LIMIT 1
#<Student id: nil>
```
but when i try to paste the query inside mysql workbench it return the student name that has the id 201410204 and the column name is "Name".
[Click to see the result of the query](http://i.stack.imgur.com/s7aBH.png)
What's the problem about my code? Thanks
|
2016/09/24
|
[
"https://Stackoverflow.com/questions/39675764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5943177/"
] |
Let me give you two solutions, one by using the **`power of rails`** and other using the **`scalability of rails`**.
**1) (Using power of rails)**
In the `Student` model create a method named `full_name` and concatenate `first_name and last_name`.
```
class Student < ActiveRecord::Base
.....
def full_name
"#{try(:first_name)} #{try(:last_name)}".to_s
end
.....
end
```
Now open console or any where you need,
```
student = Student.find(201410204)
student.full_name
```
thats it, you will get the full name.
**2) Using Scalability of rails, even can execute SQL queries.**
```
student = ActiveRecord::Base.connection.exec_query("SELECT CONCAT(first_name,' ', last_name) FROM students where students.id = 201410204")
```
It returns an array,now you can retrieve using,
`student.rows[0]`
Thats it, you will get the same result.
|
With `select` you restrict the returned columns. Your query returns only the Column `Name`. `id` and all other columns are missing. In this case you get an instance of student where all attributes are `nil`. Only the attribute `Name` is set. When you try `Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204).Name` you will see the right result.
When you want to get all attributes you have to extend your select like this `Student.select("concat(first_name, ' ', last_name) as 'Name', *").find(201410204)`
**Edit:**
I did check it for mysql on <https://de.piliapp.com/mysql-syntax-check/>, I don't know why but you have to name `*` first.
`Student.select("*, concat(first_name, ' ', last_name) as 'Name'").find(201410204)`
|
39,675,764 |
I have a table called Student, the student table contains the id, first\_name and last\_name. I am trying to select and concatenate first\_name and last\_name and display the column as "Name". This is my query:
```
Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204)
```
but it returns
```
SELECT concat(first_name, ' ', last_name) as 'Name' FROM `students` WHERE `students`.`id` = 201410204 LIMIT 1
#<Student id: nil>
```
but when i try to paste the query inside mysql workbench it return the student name that has the id 201410204 and the column name is "Name".
[Click to see the result of the query](http://i.stack.imgur.com/s7aBH.png)
What's the problem about my code? Thanks
|
2016/09/24
|
[
"https://Stackoverflow.com/questions/39675764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5943177/"
] |
You need to select the id as well:
```
Student.select(:id, "CONCAT(first_name,' ',last_name) as name").find(201410204)
2.4.1 :073 > Student.select(:id, "CONCAT(first_name,' ',last_name) as name").find(23000)
Student Load (0.9ms) SELECT "students"."id", CONCAT(first_name,' ',last_name) as name FROM "students" WHERE "students"."id" = $1 LIMIT $2 [["id", 23000], ["LIMIT", 1]]
=> #<Student id: 23000, name: "Joe Blow">
```
|
With `select` you restrict the returned columns. Your query returns only the Column `Name`. `id` and all other columns are missing. In this case you get an instance of student where all attributes are `nil`. Only the attribute `Name` is set. When you try `Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204).Name` you will see the right result.
When you want to get all attributes you have to extend your select like this `Student.select("concat(first_name, ' ', last_name) as 'Name', *").find(201410204)`
**Edit:**
I did check it for mysql on <https://de.piliapp.com/mysql-syntax-check/>, I don't know why but you have to name `*` first.
`Student.select("*, concat(first_name, ' ', last_name) as 'Name'").find(201410204)`
|
39,675,764 |
I have a table called Student, the student table contains the id, first\_name and last\_name. I am trying to select and concatenate first\_name and last\_name and display the column as "Name". This is my query:
```
Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204)
```
but it returns
```
SELECT concat(first_name, ' ', last_name) as 'Name' FROM `students` WHERE `students`.`id` = 201410204 LIMIT 1
#<Student id: nil>
```
but when i try to paste the query inside mysql workbench it return the student name that has the id 201410204 and the column name is "Name".
[Click to see the result of the query](http://i.stack.imgur.com/s7aBH.png)
What's the problem about my code? Thanks
|
2016/09/24
|
[
"https://Stackoverflow.com/questions/39675764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5943177/"
] |
Let me give you two solutions, one by using the **`power of rails`** and other using the **`scalability of rails`**.
**1) (Using power of rails)**
In the `Student` model create a method named `full_name` and concatenate `first_name and last_name`.
```
class Student < ActiveRecord::Base
.....
def full_name
"#{try(:first_name)} #{try(:last_name)}".to_s
end
.....
end
```
Now open console or any where you need,
```
student = Student.find(201410204)
student.full_name
```
thats it, you will get the full name.
**2) Using Scalability of rails, even can execute SQL queries.**
```
student = ActiveRecord::Base.connection.exec_query("SELECT CONCAT(first_name,' ', last_name) FROM students where students.id = 201410204")
```
It returns an array,now you can retrieve using,
`student.rows[0]`
Thats it, you will get the same result.
|
One solution
In model Create A method
```
def full_name
"#{self.try(:first_name)} #{self.try(:last_name)}"
end
Now
Student.find(121).full_name
```
|
39,675,764 |
I have a table called Student, the student table contains the id, first\_name and last\_name. I am trying to select and concatenate first\_name and last\_name and display the column as "Name". This is my query:
```
Student.select("concat(first_name, ' ', last_name) as 'Name'").find(201410204)
```
but it returns
```
SELECT concat(first_name, ' ', last_name) as 'Name' FROM `students` WHERE `students`.`id` = 201410204 LIMIT 1
#<Student id: nil>
```
but when i try to paste the query inside mysql workbench it return the student name that has the id 201410204 and the column name is "Name".
[Click to see the result of the query](http://i.stack.imgur.com/s7aBH.png)
What's the problem about my code? Thanks
|
2016/09/24
|
[
"https://Stackoverflow.com/questions/39675764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5943177/"
] |
You need to select the id as well:
```
Student.select(:id, "CONCAT(first_name,' ',last_name) as name").find(201410204)
2.4.1 :073 > Student.select(:id, "CONCAT(first_name,' ',last_name) as name").find(23000)
Student Load (0.9ms) SELECT "students"."id", CONCAT(first_name,' ',last_name) as name FROM "students" WHERE "students"."id" = $1 LIMIT $2 [["id", 23000], ["LIMIT", 1]]
=> #<Student id: 23000, name: "Joe Blow">
```
|
One solution
In model Create A method
```
def full_name
"#{self.try(:first_name)} #{self.try(:last_name)}"
end
Now
Student.find(121).full_name
```
|
36,486,707 |
I am new to Java and I have trouble understanding one thing:
When I am declaring an Object by assigning to a sub object (a class extending object), it doesn't have access to sub object attributes.
Why is that ?
Let's say I have this:
```
public class A {
public int a;
}
public class B extends A {
public int b;
}
```
When I create an B object like this:
```
A object = new B();
```
I don't have access to `object.b`
I am forced to declare that way
```
B object = new B();
```
Isn't my object supposed to be a B with the first way to ?
|
2016/04/07
|
[
"https://Stackoverflow.com/questions/36486707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2591935/"
] |
The object is of type `B` only at runtime, at compile time , the compiler does not that its actual type is B since the variable `object` is declared of type `A`, an explicit downcast is required
```
A object = new B();
B b = (B)object;
int x = b.b;
```
|
If you called `myfunc()`:
```
A object = myfunc();
```
And I define `myfunc()` as:
```
A myfunc() {
if (new Random().nextBoolean()) {
return new A();
} else {
return new B();
}
}
```
Can you still expect to always access `object.b`? No. `myfunc()` is only promising that it will return something of class A (or derived from class A)
|
1,805,960 |
Here is the scenario. I have an application which writes a configuration file in its directory (`user.dir`). When the user cannot write to that directory due to UAC issues, I would like to change that to write to `user.home/.appname/`. The problem is that Windows really lies to my application and writes to `user.dir` which is in the Program Files directory, but although it allows the write and the read (even after restarts) it doesn't store it there, it stores it in a hidden directory (the home directory/AppData/Local/VirtualStore/Program Files/appname), making it hard/impossible for the user to find if they want to edit the file.
However, I don't want to just change my application to write to `user.home` and be done with it because some users run the application off of a USB drive, at which point I want to use `user.dir` if it is available, because it would not be helpful to leave things around the user home directory in that scenario (on a guest computer).
So after that rather long winded background, is there a way from java to know if the local directory is really truly directly writable from Java or if vista is going to instead virtualize the directory writes to another location?
|
2009/11/26
|
[
"https://Stackoverflow.com/questions/1805960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/77779/"
] |
This problem occurs if the Java executable is not marked as Vista compatible (using the manifest). The current release from Sun is marked as compatible. So the simplest solution is to use the latest release. This means that now neither files nor registry entries are virtualised.
---
Edit from author of OP:
[Java 6 Update 10](http://java.sun.com/javase/6/webnotes/6u10.html) (bug 6722527) added the manifest to the relevant files. Bug [6737858](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6737858) addressed further issues, and is recorded as fixed in Release 12, although it is not in the release notes. For JDK 1.5, the installer was fixed in [Update 11](http://java.sun.com/j2se/1.5.0/ReleaseNotes.html), however there will be no manifests added to the exe by Sun. You can add one yourself by putting the manifest file in the same directory as the exe if it is important enough.
|
After writing your file, can you just check that the file suddenly appeared in virtualized directory? I'd do a small "touch" file at app start to set a global boolean variable userUserHome.
|
1,805,960 |
Here is the scenario. I have an application which writes a configuration file in its directory (`user.dir`). When the user cannot write to that directory due to UAC issues, I would like to change that to write to `user.home/.appname/`. The problem is that Windows really lies to my application and writes to `user.dir` which is in the Program Files directory, but although it allows the write and the read (even after restarts) it doesn't store it there, it stores it in a hidden directory (the home directory/AppData/Local/VirtualStore/Program Files/appname), making it hard/impossible for the user to find if they want to edit the file.
However, I don't want to just change my application to write to `user.home` and be done with it because some users run the application off of a USB drive, at which point I want to use `user.dir` if it is available, because it would not be helpful to leave things around the user home directory in that scenario (on a guest computer).
So after that rather long winded background, is there a way from java to know if the local directory is really truly directly writable from Java or if vista is going to instead virtualize the directory writes to another location?
|
2009/11/26
|
[
"https://Stackoverflow.com/questions/1805960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/77779/"
] |
This problem occurs if the Java executable is not marked as Vista compatible (using the manifest). The current release from Sun is marked as compatible. So the simplest solution is to use the latest release. This means that now neither files nor registry entries are virtualised.
---
Edit from author of OP:
[Java 6 Update 10](http://java.sun.com/javase/6/webnotes/6u10.html) (bug 6722527) added the manifest to the relevant files. Bug [6737858](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6737858) addressed further issues, and is recorded as fixed in Release 12, although it is not in the release notes. For JDK 1.5, the installer was fixed in [Update 11](http://java.sun.com/j2se/1.5.0/ReleaseNotes.html), however there will be no manifests added to the exe by Sun. You can add one yourself by putting the manifest file in the same directory as the exe if it is important enough.
|
1. Prepare a native EXE that loads the JVM in process (java.exe does this but you will need your own).
2. Add a manifest file (or in RC data) that specifies UAC as invoker.
3. Try writing to the folder to see if it works.
Or decide this is too much work and use a config file.
|
30,093,561 |
I need to merge two json object based on key value using javascript.
I have two different variable g and c.
terms: All values need to merge.
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
```
I tried the following code: but i merge what are have same id in 'c' variable. but i need to merge compare 'g' and 'c'.
```
var arrayList = [];
for(var i in g) {
var getid = g[i].id;
var getname = g[i].name;
var getgoal = g[i].goal;
for(var j in c){
var compareid = c[j].id;
if(getid == compareid){
var obj = {};
obj.id = getid;
obj.name = getname;
obj.goal = 'yes';
obj.circle = 'yes';
console.log(obj);
arrayList.push(obj);
}
}
}
console.log(arrayList);
```
Expected output:
```
[ { id: 36, name: 'AAA', goal: 'yes',circle: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes',circle: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes',circle: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' ,circle: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' ,circle: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' ,circle: 'yes'},
{ id: 59, name: 'GGG', goal: 'yes' ,circle: 'yes'},
{ id: 50, name: 'III', goal: 'yes' ,circle: 'no'},
{ id: 43, name: 'HHH', goal: 'yes' ,circle: 'yes'},
{ id: 35, name: 'JJJ', goal: 'yes' ,circle: 'yes'} ,
{ id: 42, name: 'ZZZ', goal: 'no' , circle: 'yes' },
{ id: 100, name: 'JJJ',goal: 'no' , circle: 'yes' }]
```
|
2015/05/07
|
[
"https://Stackoverflow.com/questions/30093561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393678/"
] |
You forgot to push `obj` in the first loop in case the id doesn't exist in `c` and to loop through `c` in case one or more id's of that object does not exist in `g`.
```
var g = [
{ id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' }
],
c = [
{ id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' }
],
arrayList = [], obj_c_processed = [];
for (var i in g) {
var obj = {id: g[i].id, name: g[i].name, goal: g[i].goal};
for (var j in c) {
if (g[i].id == c[j].id) {
obj.circle = c[j].circle;
obj_c_processed[c[j].id] = true;
}
}
obj.circle = obj.circle || 'no';
arrayList.push(obj);
}
for (var j in c){
if (typeof obj_c_processed[c[j].id] == 'undefined') {
arrayList.push({id: c[j].id, name: c[j].name, goal: 'no', circle: c[j].circle});
}
}
console.log(arrayList);
```
|
Try using jquery. Try this :
```
var g= [
{ id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ];
var c= [
{ id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ];
var combine_obj={};
$.extend(combine_obj, g, c);
```
OR using simple javascript
```
var combine_obj={};
for(var key in g) combine_obj[key]=g[key];
for(var key in c) combine_obj[key]=c[key];
```
|
30,093,561 |
I need to merge two json object based on key value using javascript.
I have two different variable g and c.
terms: All values need to merge.
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
```
I tried the following code: but i merge what are have same id in 'c' variable. but i need to merge compare 'g' and 'c'.
```
var arrayList = [];
for(var i in g) {
var getid = g[i].id;
var getname = g[i].name;
var getgoal = g[i].goal;
for(var j in c){
var compareid = c[j].id;
if(getid == compareid){
var obj = {};
obj.id = getid;
obj.name = getname;
obj.goal = 'yes';
obj.circle = 'yes';
console.log(obj);
arrayList.push(obj);
}
}
}
console.log(arrayList);
```
Expected output:
```
[ { id: 36, name: 'AAA', goal: 'yes',circle: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes',circle: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes',circle: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' ,circle: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' ,circle: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' ,circle: 'yes'},
{ id: 59, name: 'GGG', goal: 'yes' ,circle: 'yes'},
{ id: 50, name: 'III', goal: 'yes' ,circle: 'no'},
{ id: 43, name: 'HHH', goal: 'yes' ,circle: 'yes'},
{ id: 35, name: 'JJJ', goal: 'yes' ,circle: 'yes'} ,
{ id: 42, name: 'ZZZ', goal: 'no' , circle: 'yes' },
{ id: 100, name: 'JJJ',goal: 'no' , circle: 'yes' }]
```
|
2015/05/07
|
[
"https://Stackoverflow.com/questions/30093561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393678/"
] |
Using undescore.js, you can write some function like this:
```js
var a = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ];
var b = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ];
function merge_object_arrays (arr1, arr2, match) {
return _.union(
_.map(arr1, function (obj1) {
var same = _.find(arr2, function (obj2) {
return obj1[match] === obj2[match];
});
return same ? _.extend(obj1, same) : obj1;
}),
_.reject(arr2, function (obj2) {
return _.find(arr1, function(obj1) {
return obj2[match] === obj1[match];
});
})
);
}
document.getElementsByTagName('pre')[0].innerHTML = JSON.stringify(
merge_object_arrays(a, b, 'id'), null, 2
);
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<pre>
</pre>
```
Try running it here.
|
Try using jquery. Try this :
```
var g= [
{ id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ];
var c= [
{ id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ];
var combine_obj={};
$.extend(combine_obj, g, c);
```
OR using simple javascript
```
var combine_obj={};
for(var key in g) combine_obj[key]=g[key];
for(var key in c) combine_obj[key]=c[key];
```
|
30,093,561 |
I need to merge two json object based on key value using javascript.
I have two different variable g and c.
terms: All values need to merge.
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
```
I tried the following code: but i merge what are have same id in 'c' variable. but i need to merge compare 'g' and 'c'.
```
var arrayList = [];
for(var i in g) {
var getid = g[i].id;
var getname = g[i].name;
var getgoal = g[i].goal;
for(var j in c){
var compareid = c[j].id;
if(getid == compareid){
var obj = {};
obj.id = getid;
obj.name = getname;
obj.goal = 'yes';
obj.circle = 'yes';
console.log(obj);
arrayList.push(obj);
}
}
}
console.log(arrayList);
```
Expected output:
```
[ { id: 36, name: 'AAA', goal: 'yes',circle: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes',circle: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes',circle: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' ,circle: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' ,circle: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' ,circle: 'yes'},
{ id: 59, name: 'GGG', goal: 'yes' ,circle: 'yes'},
{ id: 50, name: 'III', goal: 'yes' ,circle: 'no'},
{ id: 43, name: 'HHH', goal: 'yes' ,circle: 'yes'},
{ id: 35, name: 'JJJ', goal: 'yes' ,circle: 'yes'} ,
{ id: 42, name: 'ZZZ', goal: 'no' , circle: 'yes' },
{ id: 100, name: 'JJJ',goal: 'no' , circle: 'yes' }]
```
|
2015/05/07
|
[
"https://Stackoverflow.com/questions/30093561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393678/"
] |
You forgot to push `obj` in the first loop in case the id doesn't exist in `c` and to loop through `c` in case one or more id's of that object does not exist in `g`.
```
var g = [
{ id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' }
],
c = [
{ id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' }
],
arrayList = [], obj_c_processed = [];
for (var i in g) {
var obj = {id: g[i].id, name: g[i].name, goal: g[i].goal};
for (var j in c) {
if (g[i].id == c[j].id) {
obj.circle = c[j].circle;
obj_c_processed[c[j].id] = true;
}
}
obj.circle = obj.circle || 'no';
arrayList.push(obj);
}
for (var j in c){
if (typeof obj_c_processed[c[j].id] == 'undefined') {
arrayList.push({id: c[j].id, name: c[j].name, goal: 'no', circle: c[j].circle});
}
}
console.log(arrayList);
```
|
You could do it like this,
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
for (i = 0; i < g.length; i++) { //Loop trough first array
var curID = g[i].id; //Get ID of current object
var exists = false;
for (j = 0; j < c.length; j++) { //Loop trough second array
exixts = false;
if (curID == c[j].id){ //If id from array1 exists in array2
exixts = true;
tempObj = c[j]; //Get id,object from array 2
break;
}
}
if(exixts) {
g[i]["circle"] = tempObj.circle;//If exists add circle from array2 to the record in array1
}else{
g[i]["circle"] = "no"; //If it doesn't add circle with value "no"
}
}
for (i = 0; i < c.length; i++) { //Loop trough array 2
var curObj = c[i];
var ex = true;
g.forEach(function(row) { //Loop to check if id form array2 exists in array1
if (curObj.id == row.id){
ex = false;
}
});
if(ex){ //If it doesn't exist add goal to object with value "no" and push it into array1
curObj["goal"] = "no";
g.push(curObj);
}
}
console.debug(g);
```
I've added some comments to explain what is going on in the code.
Psuedo code,
```
//Loop trough g
//get id from g[i] and check if it exists in c
//if so
//add circle from a2 to a1[i]
//Add value of circle from c onto g[i]["circle"]
//otherwise
//Add value of "no" onto g[i]["circle"]
//Loop trough c
//If id isn't in g, add row with value c[i]["goal"] = "no" to g
```
|
30,093,561 |
I need to merge two json object based on key value using javascript.
I have two different variable g and c.
terms: All values need to merge.
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
```
I tried the following code: but i merge what are have same id in 'c' variable. but i need to merge compare 'g' and 'c'.
```
var arrayList = [];
for(var i in g) {
var getid = g[i].id;
var getname = g[i].name;
var getgoal = g[i].goal;
for(var j in c){
var compareid = c[j].id;
if(getid == compareid){
var obj = {};
obj.id = getid;
obj.name = getname;
obj.goal = 'yes';
obj.circle = 'yes';
console.log(obj);
arrayList.push(obj);
}
}
}
console.log(arrayList);
```
Expected output:
```
[ { id: 36, name: 'AAA', goal: 'yes',circle: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes',circle: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes',circle: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' ,circle: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' ,circle: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' ,circle: 'yes'},
{ id: 59, name: 'GGG', goal: 'yes' ,circle: 'yes'},
{ id: 50, name: 'III', goal: 'yes' ,circle: 'no'},
{ id: 43, name: 'HHH', goal: 'yes' ,circle: 'yes'},
{ id: 35, name: 'JJJ', goal: 'yes' ,circle: 'yes'} ,
{ id: 42, name: 'ZZZ', goal: 'no' , circle: 'yes' },
{ id: 100, name: 'JJJ',goal: 'no' , circle: 'yes' }]
```
|
2015/05/07
|
[
"https://Stackoverflow.com/questions/30093561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393678/"
] |
You forgot to push `obj` in the first loop in case the id doesn't exist in `c` and to loop through `c` in case one or more id's of that object does not exist in `g`.
```
var g = [
{ id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' }
],
c = [
{ id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' }
],
arrayList = [], obj_c_processed = [];
for (var i in g) {
var obj = {id: g[i].id, name: g[i].name, goal: g[i].goal};
for (var j in c) {
if (g[i].id == c[j].id) {
obj.circle = c[j].circle;
obj_c_processed[c[j].id] = true;
}
}
obj.circle = obj.circle || 'no';
arrayList.push(obj);
}
for (var j in c){
if (typeof obj_c_processed[c[j].id] == 'undefined') {
arrayList.push({id: c[j].id, name: c[j].name, goal: 'no', circle: c[j].circle});
}
}
console.log(arrayList);
```
|
Using undescore.js, you can write some function like this:
```js
var a = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ];
var b = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ];
function merge_object_arrays (arr1, arr2, match) {
return _.union(
_.map(arr1, function (obj1) {
var same = _.find(arr2, function (obj2) {
return obj1[match] === obj2[match];
});
return same ? _.extend(obj1, same) : obj1;
}),
_.reject(arr2, function (obj2) {
return _.find(arr1, function(obj1) {
return obj2[match] === obj1[match];
});
})
);
}
document.getElementsByTagName('pre')[0].innerHTML = JSON.stringify(
merge_object_arrays(a, b, 'id'), null, 2
);
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<pre>
</pre>
```
Try running it here.
|
30,093,561 |
I need to merge two json object based on key value using javascript.
I have two different variable g and c.
terms: All values need to merge.
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
```
I tried the following code: but i merge what are have same id in 'c' variable. but i need to merge compare 'g' and 'c'.
```
var arrayList = [];
for(var i in g) {
var getid = g[i].id;
var getname = g[i].name;
var getgoal = g[i].goal;
for(var j in c){
var compareid = c[j].id;
if(getid == compareid){
var obj = {};
obj.id = getid;
obj.name = getname;
obj.goal = 'yes';
obj.circle = 'yes';
console.log(obj);
arrayList.push(obj);
}
}
}
console.log(arrayList);
```
Expected output:
```
[ { id: 36, name: 'AAA', goal: 'yes',circle: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes',circle: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes',circle: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' ,circle: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' ,circle: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' ,circle: 'yes'},
{ id: 59, name: 'GGG', goal: 'yes' ,circle: 'yes'},
{ id: 50, name: 'III', goal: 'yes' ,circle: 'no'},
{ id: 43, name: 'HHH', goal: 'yes' ,circle: 'yes'},
{ id: 35, name: 'JJJ', goal: 'yes' ,circle: 'yes'} ,
{ id: 42, name: 'ZZZ', goal: 'no' , circle: 'yes' },
{ id: 100, name: 'JJJ',goal: 'no' , circle: 'yes' }]
```
|
2015/05/07
|
[
"https://Stackoverflow.com/questions/30093561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393678/"
] |
Using undescore.js, you can write some function like this:
```js
var a = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ];
var b = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ];
function merge_object_arrays (arr1, arr2, match) {
return _.union(
_.map(arr1, function (obj1) {
var same = _.find(arr2, function (obj2) {
return obj1[match] === obj2[match];
});
return same ? _.extend(obj1, same) : obj1;
}),
_.reject(arr2, function (obj2) {
return _.find(arr1, function(obj1) {
return obj2[match] === obj1[match];
});
})
);
}
document.getElementsByTagName('pre')[0].innerHTML = JSON.stringify(
merge_object_arrays(a, b, 'id'), null, 2
);
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<pre>
</pre>
```
Try running it here.
|
You could do it like this,
```
var g = [ { id: 36, name: 'AAA', goal: 'yes' },
{ id: 40, name: 'BBB', goal: 'yes' },
{ id: 57, name: 'CCC', goal: 'yes' },
{ id: 4, name: 'DDD', goal: 'yes' },
{ id: 39, name: 'EEE', goal: 'yes' },
{ id: 37, name: 'FFF', goal: 'yes' },
{ id: 59, name: 'GGG', goal: 'yes' },
{ id: 50, name: 'III', goal: 'yes' },
{ id: 43, name: 'HHH', goal: 'yes' },
{ id: 35, name: 'JJJ', goal: 'yes' } ]
var c = [ { id: 36, name: 'AAA', circle: 'yes' },
{ id: 40, name: 'BBB', circle: 'yes' },
{ id: 57, name: 'CCC', circle: 'yes' },
{ id: 42, name: 'ZZZ', circle: 'yes' },
{ id: 4, name: 'DDD', circle: 'yes' },
{ id: 39, name: 'EEE', circle: 'yes' },
{ id: 37, name: 'FFF', circle: 'yes' },
{ id: 59, name: 'GGG', circle: 'yes' },
{ id: 43, name: 'HHH', circle: 'yes' },
{ id: 35, name: 'JJJ', circle: 'yes' },
{ id: 100, name: 'JJJ', circle: 'yes' } ]
for (i = 0; i < g.length; i++) { //Loop trough first array
var curID = g[i].id; //Get ID of current object
var exists = false;
for (j = 0; j < c.length; j++) { //Loop trough second array
exixts = false;
if (curID == c[j].id){ //If id from array1 exists in array2
exixts = true;
tempObj = c[j]; //Get id,object from array 2
break;
}
}
if(exixts) {
g[i]["circle"] = tempObj.circle;//If exists add circle from array2 to the record in array1
}else{
g[i]["circle"] = "no"; //If it doesn't add circle with value "no"
}
}
for (i = 0; i < c.length; i++) { //Loop trough array 2
var curObj = c[i];
var ex = true;
g.forEach(function(row) { //Loop to check if id form array2 exists in array1
if (curObj.id == row.id){
ex = false;
}
});
if(ex){ //If it doesn't exist add goal to object with value "no" and push it into array1
curObj["goal"] = "no";
g.push(curObj);
}
}
console.debug(g);
```
I've added some comments to explain what is going on in the code.
Psuedo code,
```
//Loop trough g
//get id from g[i] and check if it exists in c
//if so
//add circle from a2 to a1[i]
//Add value of circle from c onto g[i]["circle"]
//otherwise
//Add value of "no" onto g[i]["circle"]
//Loop trough c
//If id isn't in g, add row with value c[i]["goal"] = "no" to g
```
|
13,763,352 |
I'm a HTML/CSS developer, researching javascript solutions for building a 'family-tree' which **needs to show marriages** (from outside the family, of course) in a meaningful way.
Essentially I'm looking at basing it upon a dendrogram, based on d3.js, e.g. <http://bl.ocks.org/4063570>, but I've struggled to find anything out there that expresses 'marriages'.
Below is an image of the data I will be basing it upon:

Any help / suggestions / links would be much appreciated! I just don't know if it's even possible, but would love to use d3.js as it looks so well-made, and apparently versatile.
|
2012/12/07
|
[
"https://Stackoverflow.com/questions/13763352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390477/"
] |
There are some options, but I believe each would require a bit of work. It would help if there were one single standard for representing a family tree in JSON. I've recently noticed that geni.com has a quite in-depth API for this. Perhaps coding against their API would be a good idea for reusability...
-- Pedigree tree --
[The Pedigree Tree](http://bl.ocks.org/mbostock/2966094) might be sufficient for your needs. You'd make in-law's linkable, where if you clicked on their name the graph would redraw so you could see their lineage.
-- Bracket Layout Tree --
Similar to the Pedigree Tree, but bidirectional, this [Bracket Layout Tree](http://bl.ocks.org/jdarling/2503502) lets you handle a "here are my parents, grandparents, children, grandchildren" type view. Like the Pedigree Tree, you'd make individuals linkable to re-center the bracket on that node.
-- Force-Based Layout --
There are some interesting force-based layouts that seem promising. Take a look at [this example of a force-based layout with smart labels](http://bl.ocks.org/MoritzStefaner/1377729). An adjustment to the algorithm for how the "force" is determined could make this into a very lovely tree, with older generations above or below newer ones.
-- Cluster Dendogram (why it fails) --
The d3.js layouts I've seen that would lend themselves best to family trees assume a single node is the parent, whereas you need to represent the parent as the combination of (visually a "T" between) two nodes: one node that is a member of your tree, and one floating node that represents the in-law. Adjusting a cluster dendogram to do this should be feasible but not without significant modification.
If you--or anyone else for that matter--tackle this, let me know. I'd like to see (and benefit from) the work and may be able to contribute to it if feasible.
|
I also needed to draw pedigrees with D3 so I figured out how. I have [created examples](https://github.com/justincy/d3-pedigree-examples) that show the basic functionality and then add on advanced features such as expanding and showing descendants.
I don't know how you want to display marriages. Marriages are inherent in an ancestral pedigree but not in a descendancy chart. The code could be adapted to show spouses in the descendant nodes.
Here's a pic of how it looks. The style can be tweaked as desired.

|
13,763,352 |
I'm a HTML/CSS developer, researching javascript solutions for building a 'family-tree' which **needs to show marriages** (from outside the family, of course) in a meaningful way.
Essentially I'm looking at basing it upon a dendrogram, based on d3.js, e.g. <http://bl.ocks.org/4063570>, but I've struggled to find anything out there that expresses 'marriages'.
Below is an image of the data I will be basing it upon:

Any help / suggestions / links would be much appreciated! I just don't know if it's even possible, but would love to use d3.js as it looks so well-made, and apparently versatile.
|
2012/12/07
|
[
"https://Stackoverflow.com/questions/13763352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390477/"
] |
There are some options, but I believe each would require a bit of work. It would help if there were one single standard for representing a family tree in JSON. I've recently noticed that geni.com has a quite in-depth API for this. Perhaps coding against their API would be a good idea for reusability...
-- Pedigree tree --
[The Pedigree Tree](http://bl.ocks.org/mbostock/2966094) might be sufficient for your needs. You'd make in-law's linkable, where if you clicked on their name the graph would redraw so you could see their lineage.
-- Bracket Layout Tree --
Similar to the Pedigree Tree, but bidirectional, this [Bracket Layout Tree](http://bl.ocks.org/jdarling/2503502) lets you handle a "here are my parents, grandparents, children, grandchildren" type view. Like the Pedigree Tree, you'd make individuals linkable to re-center the bracket on that node.
-- Force-Based Layout --
There are some interesting force-based layouts that seem promising. Take a look at [this example of a force-based layout with smart labels](http://bl.ocks.org/MoritzStefaner/1377729). An adjustment to the algorithm for how the "force" is determined could make this into a very lovely tree, with older generations above or below newer ones.
-- Cluster Dendogram (why it fails) --
The d3.js layouts I've seen that would lend themselves best to family trees assume a single node is the parent, whereas you need to represent the parent as the combination of (visually a "T" between) two nodes: one node that is a member of your tree, and one floating node that represents the in-law. Adjusting a cluster dendogram to do this should be feasible but not without significant modification.
If you--or anyone else for that matter--tackle this, let me know. I'd like to see (and benefit from) the work and may be able to contribute to it if feasible.
|
This needs some work, but essentially the idea I propose is do a force layout with a special kind of node called relationship that do not draw a circle. It represents the bind between two subjects and can be the parent of more nodes.
In d3 you can extend all the data structures to fit what you want, then there is more work to bind the data but it is all customizable. Here is a sample of the data structures I would use in the force layout.
```
{
"nodes": [
{
"type": "root",
"x": 300,
"y": 300,
"fixed": true
},
{
"type": "male",
"name": "grandpa"
},
{
"type": "female",
"name": "grandma"
},
{
"type": "relationship"
},
{
"type": "male",
"name": "dad"
},
{
"type": "female",
"name": "mum"
},
{
"type": "relationship"
},
{
"type": "male",
"name": "I"
}
],
"links": [
{
"source": 0,
"target": 2
},
{
"source": 1,
"target": 2
},
{
"source": 0,
"target": 3
},
{
"source": 3,
"target": 4
},
{
"source": 4,
"target": 6
},
{
"source": 5,
"target": 6
},
{
"source": 6,
"target": 7
}
]
}
```
Hope I clarified something about the possibilities of d3.
|
13,763,352 |
I'm a HTML/CSS developer, researching javascript solutions for building a 'family-tree' which **needs to show marriages** (from outside the family, of course) in a meaningful way.
Essentially I'm looking at basing it upon a dendrogram, based on d3.js, e.g. <http://bl.ocks.org/4063570>, but I've struggled to find anything out there that expresses 'marriages'.
Below is an image of the data I will be basing it upon:

Any help / suggestions / links would be much appreciated! I just don't know if it's even possible, but would love to use d3.js as it looks so well-made, and apparently versatile.
|
2012/12/07
|
[
"https://Stackoverflow.com/questions/13763352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390477/"
] |
I also needed to draw pedigrees with D3 so I figured out how. I have [created examples](https://github.com/justincy/d3-pedigree-examples) that show the basic functionality and then add on advanced features such as expanding and showing descendants.
I don't know how you want to display marriages. Marriages are inherent in an ancestral pedigree but not in a descendancy chart. The code could be adapted to show spouses in the descendant nodes.
Here's a pic of how it looks. The style can be tweaked as desired.

|
This needs some work, but essentially the idea I propose is do a force layout with a special kind of node called relationship that do not draw a circle. It represents the bind between two subjects and can be the parent of more nodes.
In d3 you can extend all the data structures to fit what you want, then there is more work to bind the data but it is all customizable. Here is a sample of the data structures I would use in the force layout.
```
{
"nodes": [
{
"type": "root",
"x": 300,
"y": 300,
"fixed": true
},
{
"type": "male",
"name": "grandpa"
},
{
"type": "female",
"name": "grandma"
},
{
"type": "relationship"
},
{
"type": "male",
"name": "dad"
},
{
"type": "female",
"name": "mum"
},
{
"type": "relationship"
},
{
"type": "male",
"name": "I"
}
],
"links": [
{
"source": 0,
"target": 2
},
{
"source": 1,
"target": 2
},
{
"source": 0,
"target": 3
},
{
"source": 3,
"target": 4
},
{
"source": 4,
"target": 6
},
{
"source": 5,
"target": 6
},
{
"source": 6,
"target": 7
}
]
}
```
Hope I clarified something about the possibilities of d3.
|
5,807,818 |
Guys, can anyone explain the following scenario:
1) Web application has `module1.jar` in its `lib` directory. There is a class `A` in that module:
```
package module1;
import module2.B;
public interface IA {
void methodOk() {}
void methodWithB(B param) {}
}
package module1;
import module2.B;
public class A implements IA {
public A() {}
//...
void methodWithB(B param) {
//do job on B
}
}
```
2) `module2.jar` is absent - it is not in the classpath.
3) Application **is able** to create objects of class `A` though it's missing the dependency. In application a method A.methodOk() is called.
Would be cool if you could give a reference to any spec on this.
Thanks a lot.
|
2011/04/27
|
[
"https://Stackoverflow.com/questions/5807818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336184/"
] |
Since the code is already compiled, it will not throw an error until you directly use class `B`. From the looks of your code, you don't actually use an instance of `B` for anything.
|
If B is not *used* by A anywhere, then the resulting bytecode will have no reference to module2.B, therefore it gets compiled away. No dependency exists, *except* at compilation in this case.
If the question is unclear and B *is* used in A somewhere, then I'd be interested in seeing more code to try to determine what's going on.
|
5,807,818 |
Guys, can anyone explain the following scenario:
1) Web application has `module1.jar` in its `lib` directory. There is a class `A` in that module:
```
package module1;
import module2.B;
public interface IA {
void methodOk() {}
void methodWithB(B param) {}
}
package module1;
import module2.B;
public class A implements IA {
public A() {}
//...
void methodWithB(B param) {
//do job on B
}
}
```
2) `module2.jar` is absent - it is not in the classpath.
3) Application **is able** to create objects of class `A` though it's missing the dependency. In application a method A.methodOk() is called.
Would be cool if you could give a reference to any spec on this.
Thanks a lot.
|
2011/04/27
|
[
"https://Stackoverflow.com/questions/5807818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336184/"
] |
Since the code is already compiled, it will not throw an error until you directly use class `B`. From the looks of your code, you don't actually use an instance of `B` for anything.
|
Look at it from the perspective of the classloader. If you never have to load the class, you don't care if the bytecode for that class is missing.
Your question is really, "What triggers classloading?"
Two reasons I can think of off the top of my head are:
- Construction
- Static access
|
5,807,818 |
Guys, can anyone explain the following scenario:
1) Web application has `module1.jar` in its `lib` directory. There is a class `A` in that module:
```
package module1;
import module2.B;
public interface IA {
void methodOk() {}
void methodWithB(B param) {}
}
package module1;
import module2.B;
public class A implements IA {
public A() {}
//...
void methodWithB(B param) {
//do job on B
}
}
```
2) `module2.jar` is absent - it is not in the classpath.
3) Application **is able** to create objects of class `A` though it's missing the dependency. In application a method A.methodOk() is called.
Would be cool if you could give a reference to any spec on this.
Thanks a lot.
|
2011/04/27
|
[
"https://Stackoverflow.com/questions/5807818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336184/"
] |
If B is not *used* by A anywhere, then the resulting bytecode will have no reference to module2.B, therefore it gets compiled away. No dependency exists, *except* at compilation in this case.
If the question is unclear and B *is* used in A somewhere, then I'd be interested in seeing more code to try to determine what's going on.
|
Look at it from the perspective of the classloader. If you never have to load the class, you don't care if the bytecode for that class is missing.
Your question is really, "What triggers classloading?"
Two reasons I can think of off the top of my head are:
- Construction
- Static access
|
68,804,918 |
I have only one button. In css you can use *button:active { do stuff }* and it will become valid once and after the button is clicked, so interacting with other objects (clicking on a image) will cause
the statement to be null. How Can I translate this into java script?
Something like that:
```
const Ham_Button = document.querySelector('button');
while (Ham_Button.isActive)
{
do stuff
}
```
I tried this:
```
const Ham_Button = document.querySelector('button');
const ClickEvent = function() {
Hidden_Nav.style.display = "block";
}
Ham_Button.addEventListener("click", ClickEvent);
```
But the event is triggered only and only when I click, not after, when the element is still the last interacted object.
|
2021/08/16
|
[
"https://Stackoverflow.com/questions/68804918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16680185/"
] |
>
> How do you achieve the same when using Cloud Storage or Azure Storage?
>
>
>
In Azure Storage, you don't have to do anything special. The ownership of objects (blobs) always lie with the storage account owner where the blob is being uploaded. They can delegate permissions to manage the blob to some other users but the ownership always remains with the account owner.
|
Firebase Storage is closer to Dropbox or Google Drive where the owner is technically the bucket, Should you want to track who the owner is, you can however use the metadata
```js
var newMetadata = {
customMetadata : {
'owner': auth().currentUser.uid
}
};
storageItemReference.updateMetadata(newMetadata)
.then((metadata) => {
// Updated metadata for your storage item is returned in the Promise
}).catch((error) => {
// Uh-oh, an error occurred!
});
```
* <https://firebase.google.com/docs/storage/web/file-metadata#custom_metadata>
If you are finding that users are able to delete storage when they shouldn't, You can also control this behavior from Security Rules
```js
service firebase.storage {
match /b/{bucket}/o {
// A read rule can be divided into read and list rules
match /images/{imageId} {
// Applies to single document read requests
allow get: if <condition>;
// Applies to list and listAll requests (Rules Version 2)
allow list: if <condition>;
// A write rule can be divided into create, update, and delete rules
match /images/{imageId} {
// Applies to writes to nonexistent files
allow create: if <condition>;
// Applies to updates to file metadata
allow update: if <condition>;
// Applies to delete operations
allow delete: if <condition>;
}
}
}
}
```
Source: <https://firebase.google.com/docs/storage/security/core-syntax>
|
68,804,918 |
I have only one button. In css you can use *button:active { do stuff }* and it will become valid once and after the button is clicked, so interacting with other objects (clicking on a image) will cause
the statement to be null. How Can I translate this into java script?
Something like that:
```
const Ham_Button = document.querySelector('button');
while (Ham_Button.isActive)
{
do stuff
}
```
I tried this:
```
const Ham_Button = document.querySelector('button');
const ClickEvent = function() {
Hidden_Nav.style.display = "block";
}
Ham_Button.addEventListener("click", ClickEvent);
```
But the event is triggered only and only when I click, not after, when the element is still the last interacted object.
|
2021/08/16
|
[
"https://Stackoverflow.com/questions/68804918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16680185/"
] |
For Google Cloud Storage, the equivalent of uploading an object with the `x-amz-acl=bucket-owner-full-control` is to upload an object with the `x-goog-acl=bucket-owner-full-control` header. Switching the `amz` to `goog` works for most headers. There's a [translation table](https://cloud.google.com/storage/docs/migrating#custommeta) of S3 to GCS headers.
In addition, if you're looking to make sure that all objects in a bucket are accessible by only the bucket owner, you may find it more convenient to use [Uniform Bucket Level Access](https://cloud.google.com/storage/docs/uniform-bucket-level-access). Once enabled, individual object ownership within the bucket no longer exists, and you no longer need to specify that header with each upload.
You can enable Uniform Bucket Level Access from the UI, the API, or via this command: `gsutil uniformbucketlevelaccess set on gs://BUCKET_NAME`
|
Firebase Storage is closer to Dropbox or Google Drive where the owner is technically the bucket, Should you want to track who the owner is, you can however use the metadata
```js
var newMetadata = {
customMetadata : {
'owner': auth().currentUser.uid
}
};
storageItemReference.updateMetadata(newMetadata)
.then((metadata) => {
// Updated metadata for your storage item is returned in the Promise
}).catch((error) => {
// Uh-oh, an error occurred!
});
```
* <https://firebase.google.com/docs/storage/web/file-metadata#custom_metadata>
If you are finding that users are able to delete storage when they shouldn't, You can also control this behavior from Security Rules
```js
service firebase.storage {
match /b/{bucket}/o {
// A read rule can be divided into read and list rules
match /images/{imageId} {
// Applies to single document read requests
allow get: if <condition>;
// Applies to list and listAll requests (Rules Version 2)
allow list: if <condition>;
// A write rule can be divided into create, update, and delete rules
match /images/{imageId} {
// Applies to writes to nonexistent files
allow create: if <condition>;
// Applies to updates to file metadata
allow update: if <condition>;
// Applies to delete operations
allow delete: if <condition>;
}
}
}
}
```
Source: <https://firebase.google.com/docs/storage/security/core-syntax>
|
25,731,716 |
Hi I have an input field where I want to do validation such that input only has numbers but with dashes and 11 number maximum
```
i.e 1233-224-1234
```
I have following validation applied that only accepts numbers
```
<input ng-pattern="customNum" ng-model=value.id />
In my controller I have
function myCtrl($scope) {
$scope.customNum = /^\d+$/;
}
```
Please let me know how i can update this so that 13 digits are entered out of which 11 are numbers and two are dashes.
Thanks
|
2014/09/08
|
[
"https://Stackoverflow.com/questions/25731716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1764254/"
] |
Please see here :<http://jsbin.com/talaz/1/>
```
<form name="form" class="css-form" novalidate>
<input type="text" ng-model="code" name="code" ng-pattern='/^\d{4}-\d{3}-\d{4}$/' />Code :{{code}}<br />
<span ng-show="form.size.$error.pattern ">
The code need to falow that 1234-123-1234 pattern</span>
</form>
```
|
You can try this if the digits are not fixed:
```
^\d+[-]\d+[-]\d+$
```
If your digits are fixed then :
```
^\d{4}-\d{3}-\d{4}$
```
|
25,731,716 |
Hi I have an input field where I want to do validation such that input only has numbers but with dashes and 11 number maximum
```
i.e 1233-224-1234
```
I have following validation applied that only accepts numbers
```
<input ng-pattern="customNum" ng-model=value.id />
In my controller I have
function myCtrl($scope) {
$scope.customNum = /^\d+$/;
}
```
Please let me know how i can update this so that 13 digits are entered out of which 11 are numbers and two are dashes.
Thanks
|
2014/09/08
|
[
"https://Stackoverflow.com/questions/25731716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1764254/"
] |
Please see here :<http://jsbin.com/talaz/1/>
```
<form name="form" class="css-form" novalidate>
<input type="text" ng-model="code" name="code" ng-pattern='/^\d{4}-\d{3}-\d{4}$/' />Code :{{code}}<br />
<span ng-show="form.size.$error.pattern ">
The code need to falow that 1234-123-1234 pattern</span>
</form>
```
|
If you want a reusable validation that you can use in a lot of places and change in one place you can use a custom validator directive. I've called it a creditcard validator just for the example.
```
<form name="form">
<input type="text" ng-model="user.creditcard" name="creditcardNumber" validate-creditcard>
<span ng-show="form.creditcardNumber.$error.creditcard">
This is not a valid credit card number.
</span>
</form>
```
```
app.directive('validateCreditcard', function() {
var creditcardRegex = /^\d{4}-\d{3}-\d{4}$/;
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, el, attr, ngModelCtrl) {
ngModelCtrl.$parsers.unshift(function(input) {
var valid = creditcardRegex.test(input);
ngModelCtrl.$setValidity('creditcard', valid);
return valid;
});
}
};
});
```
[example on plnkr](http://plnkr.co/edit/ZhJUx3s24gaxeLH8axGo?p=preview)
|
14,897,971 |
I am writing a test script for a website and we have two servers running the script. I would like be able to access the name of the server to set which username should be used within the script.
My properties file says:
```
grinder.hostID = 1
```
My script says:
```
if grinder.hostID:
offset = 1
```
When I go to run the script, it tells me that it is unable to find hostID. Am I missing a basic functionality of the hostID? How am I able to access the properties file's hostID within my script?
Thanks!
|
2013/02/15
|
[
"https://Stackoverflow.com/questions/14897971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2076059/"
] |
Might be more reliable to get info about the host you are running on programmatically. That way you don't need to worry about accidentally setting identical (or otherwise incorrect) values for grinder.hostid on your various agents. You could use something like this:
```
import socket
# ...
host_id = socket.gethostname()
# or alternately
host_id = socket.gethostname().split('.')[0]
```
|
Are you sure that your `properties` is being imported in your `script`
|
6,974,943 |
>
> **Possible Duplicates:**
>
> [NSString retainCount is 2147483647](https://stackoverflow.com/questions/5483357/nsstring-retaincount-is-2147483647)
>
> [Objective C NSString\* property retain count oddity](https://stackoverflow.com/questions/403112/objective-c-nsstring-property-retain-count-oddity)
>
>
>
Have a look at the following code:
```
NSString* testString = [[NSString alloc] initWithString:@"Test"];
NSLog(@"[testString retainCount] = %d", [testString retainCount] );
NSMutableArray* ma = [[NSMutableArray alloc] init];
[ma insertObject:testString atIndex:0];
[testString release];
NSLog(@"%@", [ma objectAtIndex:0]);
```
This is the output on the console :
```
[testString retainCount] = 2147483647
Test
```
How can this happen? I expected 1 not 2147483647!
|
2011/08/07
|
[
"https://Stackoverflow.com/questions/6974943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734444/"
] |
You initiate your NSString object with **string literal** and 2 following things happen:
1. As NSString is immutable -initWithString: method optimizes string creation so that your testString actually points to a same string you create it with (@"Test")
2. @"Test" is a **string literal** and it is created in compile time and lives in a specific address space - you cannot dealloc it, release and retain does not affect its retain count and it is always INT\_MAX
With all mentioned above you still should work with your string object following memory management rules (as you created it with alloc/init you should release it) and you'll be fine
|
You can only have two expectations for the result of retainCount:
1) It's greater than 1. You cannot predict what number it will actually be because you don't know who else is using it. You don't know how somebody else is using it. It's not a number you should care about.
2) People will tell you not to use it. Because you shouldn't. Use the rules to balance your retains and releases. Do not use retainCount. It will frustrate and confuse you, for no value.
|
868,000 |
A given text states, “Every real number except zero has a multiplicative inverse" (where mul-
tiplicative inverse of a real number x is a real number y such that xy = 1).
It offers the following translation:
$$\forall x((x\neq 0) \rightarrow \exists y(xy = 1)).$$
I personally translated the statement as:
$$\forall x \exists y((x\neq 0)\rightarrow (xy = 1)).$$
Are these two statements logically equivalent?
My reasoning being, for every real number x, there exists a real number y, such that if x does not equal zero, then the product of x and y equals 1.
|
2014/07/15
|
[
"https://math.stackexchange.com/questions/868000",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/128182/"
] |
Yes :
>
> $∀x((x \ne 0 ) → ∃y(xy = 1 ))$
>
>
>
and
>
> $∀x∃y((x \ne 0) → (xy = 1))$
>
>
>
are logically equivalent, because :
>
>
> >
> > $\vdash \exists y (\alpha \rightarrow \beta) \leftrightarrow (\alpha \rightarrow \exists y \beta) \quad $ if $y$ is not *free* in $\alpha$.
> >
> >
> >
>
>
>
In your case, $\alpha$ is $(x \ne 0 )$ and $y$ is not *free* in it.
|
Yes, it is a general principle that if $y$ does not appear in $\varphi$, then the following are equivalent.
1. $\varphi \rightarrow \exists y(\psi)$
2. $\exists y(\varphi \rightarrow \psi)$
|
868,000 |
A given text states, “Every real number except zero has a multiplicative inverse" (where mul-
tiplicative inverse of a real number x is a real number y such that xy = 1).
It offers the following translation:
$$\forall x((x\neq 0) \rightarrow \exists y(xy = 1)).$$
I personally translated the statement as:
$$\forall x \exists y((x\neq 0)\rightarrow (xy = 1)).$$
Are these two statements logically equivalent?
My reasoning being, for every real number x, there exists a real number y, such that if x does not equal zero, then the product of x and y equals 1.
|
2014/07/15
|
[
"https://math.stackexchange.com/questions/868000",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/128182/"
] |
Yes :
>
> $∀x((x \ne 0 ) → ∃y(xy = 1 ))$
>
>
>
and
>
> $∀x∃y((x \ne 0) → (xy = 1))$
>
>
>
are logically equivalent, because :
>
>
> >
> > $\vdash \exists y (\alpha \rightarrow \beta) \leftrightarrow (\alpha \rightarrow \exists y \beta) \quad $ if $y$ is not *free* in $\alpha$.
> >
> >
> >
>
>
>
In your case, $\alpha$ is $(x \ne 0 )$ and $y$ is not *free* in it.
|
Yes, it is correct.
This principle is known as "null quantification rule".
In this case, the left-hand $x$ is independent of domain $y$. So, we can place $y$ domain on left hand side.
Follow the below link to get more details about null quantification rule.
<https://gateoverflow.in/130504/null-qunatification-rule>
|
868,000 |
A given text states, “Every real number except zero has a multiplicative inverse" (where mul-
tiplicative inverse of a real number x is a real number y such that xy = 1).
It offers the following translation:
$$\forall x((x\neq 0) \rightarrow \exists y(xy = 1)).$$
I personally translated the statement as:
$$\forall x \exists y((x\neq 0)\rightarrow (xy = 1)).$$
Are these two statements logically equivalent?
My reasoning being, for every real number x, there exists a real number y, such that if x does not equal zero, then the product of x and y equals 1.
|
2014/07/15
|
[
"https://math.stackexchange.com/questions/868000",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/128182/"
] |
Yes, it is a general principle that if $y$ does not appear in $\varphi$, then the following are equivalent.
1. $\varphi \rightarrow \exists y(\psi)$
2. $\exists y(\varphi \rightarrow \psi)$
|
Yes, it is correct.
This principle is known as "null quantification rule".
In this case, the left-hand $x$ is independent of domain $y$. So, we can place $y$ domain on left hand side.
Follow the below link to get more details about null quantification rule.
<https://gateoverflow.in/130504/null-qunatification-rule>
|
53,949,700 |
I'm making myself a portfolio website, and I'm wondering how to scroll the content inside a fixed div relative to the scrolling of the page.
I've tried placing an absolute div over the fixed div, but then all the content doesn't stay inside the fixed div, and trying inside the fixed div means the content stays still, and I don't want to add a separate scroll bar.
<http://jsfiddle.net/wef2buyh/1/>
```
<div class = "title">
<h1 style = "font-size: 200%;">A Portfolio</h1>
<h1 >Barney</h1>
</div>
<div class = "main" id = "mainDiv">
<div id = "innerDiv" class = "fixed" style="height:1500px;background-color: rgb(255, 255, 255);font-size:36px; transform: translate(0%, 500px)">
</div>
</div>
<div style = "size: 100%; position: absolute; top: 1000px; left: 20px; overflow: hidden; clip: rect(10px, scrollY ,2px, 100%); background-attachment: fixed" id = "div">
<p id = "scrollable">Text, blah blah. </p>
</div>
```
I'm expecting the text to inside the white box, but instead, it flows out of it.
|
2018/12/27
|
[
"https://Stackoverflow.com/questions/53949700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5741280/"
] |
Use [`rand`](https://perldoc.perl.org/functions/rand.html).
Five random number from 0 to 50:
```
@randoms = map {int(rand(50))} 1..5;
```
In your one-liner:
```
perl -F'\t' -lane 'print join ",", @F[map {int(rand(50))} 1..5]' inputfile
```
To use the same random column indexes for each line, use a `BEGIN` block that only executes once at the start of the program:
```
perl -F'\t' -lane 'BEGIN {@rand = map {int(rand(50))} 1..5]}; print join ",", @F[@rand]' inputfile
```
|
Thank you all very much !!
I solved the problem following your suggestions (see below):
* Randomly selects $extractColumnCount columns from the range 2-$fileColumnCount,
sort them and place them in $cols\_new\_temp
cols\_new\_temp=$(echo $(shuf -i 2-$fileColumnCount -n $extractColumnCount | sort -n))
======================================================================================
echo $cols\_new\_temp
=====================
* Here I add commas to separate the array of column labels and place it in $cols\_new
cols\_new=$(echo $cols\_new\_temp | sed 's/ /,/g')
==================================================
echo $cols\_new
===============
* This Perl oneliner retrieves a subset of pre-specified randomly-selected columns ($cols\_new) from the file specified in $file1, adding the first column and the output column. The resulting file is then saved as $file2
output\_col=1
=============
time perl -F',' -lane "print join q(,), @F[split "," $output\_col,$cols\_new]" $file1 > $file2
==============================================================================================
|
53,949,700 |
I'm making myself a portfolio website, and I'm wondering how to scroll the content inside a fixed div relative to the scrolling of the page.
I've tried placing an absolute div over the fixed div, but then all the content doesn't stay inside the fixed div, and trying inside the fixed div means the content stays still, and I don't want to add a separate scroll bar.
<http://jsfiddle.net/wef2buyh/1/>
```
<div class = "title">
<h1 style = "font-size: 200%;">A Portfolio</h1>
<h1 >Barney</h1>
</div>
<div class = "main" id = "mainDiv">
<div id = "innerDiv" class = "fixed" style="height:1500px;background-color: rgb(255, 255, 255);font-size:36px; transform: translate(0%, 500px)">
</div>
</div>
<div style = "size: 100%; position: absolute; top: 1000px; left: 20px; overflow: hidden; clip: rect(10px, scrollY ,2px, 100%); background-attachment: fixed" id = "div">
<p id = "scrollable">Text, blah blah. </p>
</div>
```
I'm expecting the text to inside the white box, but instead, it flows out of it.
|
2018/12/27
|
[
"https://Stackoverflow.com/questions/53949700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5741280/"
] |
Your `perl -e'...$cols_new...'` is using single shell quotes, so the shell is not interpolating the variable.
While you can use interpolation or a command line argument to get information from the shell to a perl oneliner, often an environment variable is less troublesome:
```
export cols_new=1,2
perl -F'\t' -lane 'print join ",", @F[split /,/, $ENV{cols_new}]' inputfile
```
|
Thank you all very much !!
I solved the problem following your suggestions (see below):
* Randomly selects $extractColumnCount columns from the range 2-$fileColumnCount,
sort them and place them in $cols\_new\_temp
cols\_new\_temp=$(echo $(shuf -i 2-$fileColumnCount -n $extractColumnCount | sort -n))
======================================================================================
echo $cols\_new\_temp
=====================
* Here I add commas to separate the array of column labels and place it in $cols\_new
cols\_new=$(echo $cols\_new\_temp | sed 's/ /,/g')
==================================================
echo $cols\_new
===============
* This Perl oneliner retrieves a subset of pre-specified randomly-selected columns ($cols\_new) from the file specified in $file1, adding the first column and the output column. The resulting file is then saved as $file2
output\_col=1
=============
time perl -F',' -lane "print join q(,), @F[split "," $output\_col,$cols\_new]" $file1 > $file2
==============================================================================================
|
53,949,700 |
I'm making myself a portfolio website, and I'm wondering how to scroll the content inside a fixed div relative to the scrolling of the page.
I've tried placing an absolute div over the fixed div, but then all the content doesn't stay inside the fixed div, and trying inside the fixed div means the content stays still, and I don't want to add a separate scroll bar.
<http://jsfiddle.net/wef2buyh/1/>
```
<div class = "title">
<h1 style = "font-size: 200%;">A Portfolio</h1>
<h1 >Barney</h1>
</div>
<div class = "main" id = "mainDiv">
<div id = "innerDiv" class = "fixed" style="height:1500px;background-color: rgb(255, 255, 255);font-size:36px; transform: translate(0%, 500px)">
</div>
</div>
<div style = "size: 100%; position: absolute; top: 1000px; left: 20px; overflow: hidden; clip: rect(10px, scrollY ,2px, 100%); background-attachment: fixed" id = "div">
<p id = "scrollable">Text, blah blah. </p>
</div>
```
I'm expecting the text to inside the white box, but instead, it flows out of it.
|
2018/12/27
|
[
"https://Stackoverflow.com/questions/53949700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5741280/"
] |
You can just do the random number generation in Perl:
```
perl -F'\t' -lane 'BEGIN { @cols = map int(rand 50) + 1, 1 .. 5 } print join ",", @F[@cols]' inputfile
```
|
Thank you all very much !!
I solved the problem following your suggestions (see below):
* Randomly selects $extractColumnCount columns from the range 2-$fileColumnCount,
sort them and place them in $cols\_new\_temp
cols\_new\_temp=$(echo $(shuf -i 2-$fileColumnCount -n $extractColumnCount | sort -n))
======================================================================================
echo $cols\_new\_temp
=====================
* Here I add commas to separate the array of column labels and place it in $cols\_new
cols\_new=$(echo $cols\_new\_temp | sed 's/ /,/g')
==================================================
echo $cols\_new
===============
* This Perl oneliner retrieves a subset of pre-specified randomly-selected columns ($cols\_new) from the file specified in $file1, adding the first column and the output column. The resulting file is then saved as $file2
output\_col=1
=============
time perl -F',' -lane "print join q(,), @F[split "," $output\_col,$cols\_new]" $file1 > $file2
==============================================================================================
|
8,736,670 |
I am using jQuery UI Autocomplete plugin for better data input in my ASP.NET web application.
<http://jqueryui.com/demos/autocomplete/>
However, I think I have somehow lost in this plugin.
I would like to ask what I should do in order to use this autocomplete function with the data retrieve from database?
I expect Ajax should be used for the real-time search,
but I have no idea how it can be done after looking at the demo in the website above.
Thanks so much.
**Update:**
Here is the code I have tried, doesn't work, but no error in firebug too.
```
$('#FirstName').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Contact/FirstNameLookup?firstName=",
type: "POST",
data: {
"firstName": $('#FirstName').val()
},
success: function (data) {
response($.map(data, function (item) {
return {
label: item.FirstName,
value: item.FistName
}
}));
}
});
}
});
```
|
2012/01/05
|
[
"https://Stackoverflow.com/questions/8736670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/878334/"
] |
You need to create an action that does the lookup and returns the result as a JsonResult
e.g.
```
public ActionResult FirstNameLookup(string firstName)
{
var contacts = FindContacts(firstname);
return Json(contacts.ToArray(), JsonRequestBehavior.AllowGet);
}
```
|
I'm not sure if this will solve all your problems but here are a couple of edits you can make.
1. you don't need the "?firstname=" part of the url since you are using the data parameter for you ajax request.
2. rather than grabbing your search term with $('#FirstName').val(), try using the term property of the request object (request.term).
for example:
```
$('#FirstName').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Contact/FirstNameLookup",
type: "POST",
data: {
"firstName": request.term
},
success: function (data) {
response($.map(data, function (item) {
return {
label: item.FirstName,
value: item.FistName
}
}));
}
});
}
});
```
|
16,471,774 |
I am working on an app where i am adding panelbars (multiselection) using JSP Wrapper (which means no ID to each of the panels), and inside those have the grids.
The grids are storing data specific to the selected person, who are displayed as list items(images) on the top of the page.
What I want to do is that when user changes the selection of person, from the current selected to another, collapse all the panels of the kendo panelbar. This would help in reloading the data of the new person, because when the user will select/expand the panel to see the data, i would catch the event and reload the grid with a new Datasource, based on the selected person.
I hope I make sense here, but I am not sure how to collapse all the panels of the PanelBar.
Any Suggestions??
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16471774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927044/"
] |
If the `id` of your `PanelBar` is `panel`, do:
```
$("#panel").data("kendoPanelBar").collapse($("li", "#panelbar"));
```
or
```
var panelbar = $("#panelbar").data("kendoPanelBar");
panelbar.collapse($("li", panelbar.element));
```
i.e. we will `collapse` every `li` element under `#panelbar`.
**EDIT**: If you want to remove the selection, add:
```
$(".k-state-selected", panelbar.element).removeClass("k-state-selected");
```
|
HTML
```
<ul id="palettePanelBar">
<li id="item1" class="k-state-active">
<!--Some Data-->
</li>
<li id="item2">
<!--Some Data for second item-->
</li>
</ul>
```
Javascript
```
var panelBar = $("#palettePanelBar").data("kendoPanelBar");
panelBar.expand($('[id^="item"]'));
```
|
16,471,774 |
I am working on an app where i am adding panelbars (multiselection) using JSP Wrapper (which means no ID to each of the panels), and inside those have the grids.
The grids are storing data specific to the selected person, who are displayed as list items(images) on the top of the page.
What I want to do is that when user changes the selection of person, from the current selected to another, collapse all the panels of the kendo panelbar. This would help in reloading the data of the new person, because when the user will select/expand the panel to see the data, i would catch the event and reload the grid with a new Datasource, based on the selected person.
I hope I make sense here, but I am not sure how to collapse all the panels of the PanelBar.
Any Suggestions??
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16471774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927044/"
] |
If the `id` of your `PanelBar` is `panel`, do:
```
$("#panel").data("kendoPanelBar").collapse($("li", "#panelbar"));
```
or
```
var panelbar = $("#panelbar").data("kendoPanelBar");
panelbar.collapse($("li", panelbar.element));
```
i.e. we will `collapse` every `li` element under `#panelbar`.
**EDIT**: If you want to remove the selection, add:
```
$(".k-state-selected", panelbar.element).removeClass("k-state-selected");
```
|
You can use this block to collapse all panel and as a bonus to the answer, you can expand only the selected after that in this way:
```
var panelBar = $("#importCvPanelbar").data("kendoPanelBar");
panelBar.collapse($("li"));// will collapse all panel item
panelBar.bind("select", function(e) {
var itemId = $(e.item)[0].id;
panelBar.expand(itemId);// will expand the selected one
});
```
|
16,471,774 |
I am working on an app where i am adding panelbars (multiselection) using JSP Wrapper (which means no ID to each of the panels), and inside those have the grids.
The grids are storing data specific to the selected person, who are displayed as list items(images) on the top of the page.
What I want to do is that when user changes the selection of person, from the current selected to another, collapse all the panels of the kendo panelbar. This would help in reloading the data of the new person, because when the user will select/expand the panel to see the data, i would catch the event and reload the grid with a new Datasource, based on the selected person.
I hope I make sense here, but I am not sure how to collapse all the panels of the PanelBar.
Any Suggestions??
|
2013/05/09
|
[
"https://Stackoverflow.com/questions/16471774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/927044/"
] |
HTML
```
<ul id="palettePanelBar">
<li id="item1" class="k-state-active">
<!--Some Data-->
</li>
<li id="item2">
<!--Some Data for second item-->
</li>
</ul>
```
Javascript
```
var panelBar = $("#palettePanelBar").data("kendoPanelBar");
panelBar.expand($('[id^="item"]'));
```
|
You can use this block to collapse all panel and as a bonus to the answer, you can expand only the selected after that in this way:
```
var panelBar = $("#importCvPanelbar").data("kendoPanelBar");
panelBar.collapse($("li"));// will collapse all panel item
panelBar.bind("select", function(e) {
var itemId = $(e.item)[0].id;
panelBar.expand(itemId);// will expand the selected one
});
```
|
148,963 |
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.
[Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways:
1. Use threads
2. Use wxYield
3. Chunk the work and do it in the IDLE event handler
Which method have *you* found to be the most effective ? Techniques from other frameworks (like Qt, GTK or Windows API) are also welcome.
|
2008/09/29
|
[
"https://Stackoverflow.com/questions/148963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] |
Threads or processes depending on the application. Sometimes it's actually best to have the GUI be it's own program and just send asynchronous calls to other programs when it has work to do. You'll still end up having multiple threads in the GUI to monitor for results, but it can simplify things if the work being done is complex and not directly connected to the GUI.
|
I use threads so the GUI's main event loop never blocks.
|
148,963 |
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.
[Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways:
1. Use threads
2. Use wxYield
3. Chunk the work and do it in the IDLE event handler
Which method have *you* found to be the most effective ? Techniques from other frameworks (like Qt, GTK or Windows API) are also welcome.
|
2008/09/29
|
[
"https://Stackoverflow.com/questions/148963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] |
Threads -
Let's use a simple 2-layer view (GUI, application logic).
The application logic work should be done in a separate Python thread. For Asynchronous events that need to propagate up to the GUI layer, use wx's event system to post custom events. Posting wx events is thread safe so you could conceivably do it from multiple contexts.
Working in the other direction (GUI input events triggering application logic), I have found it best to home-roll a custom event system. Use the Queue module to have a thread-safe way of pushing and popping event objects. Then, for every synchronous member function, pair it with an async version that pushes the sync function object and the parameters onto the event queue.
This works particularly well if only a single application logic-level operation can be performed at a time. The benefit of this model is that synchronization is simple - each synchronous function works within it's own context sequentially from start to end without worry of pre-emption or hand-coded yielding. You will not need locks to protect your critical sections. At the end of the function, post an event to the GUI layer indicating that the operation is complete.
You could scale this to allow multiple application-level threads to exist, but the usual concerns with synchronization will re-appear.
*edit* - Forgot to mention the beauty of this is that it is possible to completely decouple the application logic from the GUI code. The modularity helps if you ever decide to use a different framework or use provide a command-line version of the app. To do this, you will need an intermediate event dispatcher (application level -> GUI) that is implemented by the GUI layer.
|
I use threads so the GUI's main event loop never blocks.
|
148,963 |
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.
[Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways:
1. Use threads
2. Use wxYield
3. Chunk the work and do it in the IDLE event handler
Which method have *you* found to be the most effective ? Techniques from other frameworks (like Qt, GTK or Windows API) are also welcome.
|
2008/09/29
|
[
"https://Stackoverflow.com/questions/148963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] |
Definitely threads. Why? The future is multi-core. Almost any new CPU has more than one core or if it has just one, it might support hyperthreading and thus pretending it has more than one. To effectively make use of multi-core CPUs (and Intel is planing to go up to 32 cores in the not so far future), you need multiple threads. If you run all in one main thread (usually the UI thread is the main thread), users will have CPUs with 8, 16 and one day 32 cores and your application never uses more than one of these, IOW it runs much, much slower than it could run.
Actual if you plan an application nowadays, I would go away of the classical design and think of a master/slave relationship. Your UI is the master, it's only task is to interact with the user. That is displaying data to the user and gathering user input. Whenever you app needs to "process any data" (even small amounts and much more important big ones), create a "task" of any kind, forward this task to a background thread and make the thread perform the task, providing feedback to the UI (e.g. how many percent it has completed or just if the task is still running or not, so the UI can show a "work-in-progress indicator"). If possible, split the task into many small, independent sub-tasks and run more than one background process, feeding one sub-task to each of them. That way your application can really benefit from multi-core and get faster the more cores CPUs have.
Actually companies like Apple and Microsoft are already planing on how to make their still most single threaded UIs themselves multithreaded. Even with the approach above, you may one day have the situation that the UI is the bottleneck itself. The background processes can process data much faster than the UI can present it to the user or ask the user for input. Today many UI frameworks are little thread-safe, many not thread-safe at all, but that will change. Serial processing (doing one task after another) is a dying design, parallel processing (doing many task at once) is where the future goes. Just look at graphic adapters. Even the most modern NVidia card has a pitiful performance, if you look at the processing speed in MHz/GHz of the GPU alone. How comes it can beat the crap out of CPUs when it comes to 3D calculations? Simple: Instead of calculating one polygon point or one texture pixel after another, it calculates many of them in parallel (actually a whole bunch at the same time) and that way it reaches a throughput that still makes CPUs cry. E.g. the ATI X1900 (to name the competitor as well) has 48 shader units!
|
For some types of operations, using separate processes makes a lot of sense. Back in the day, spawning a process incurred a lot of overhead. With modern hardware this overhead is hardly even a blip on the screen. This is especially true if you're spawning a long running process.
One (arguable) advantage is that it's a simpler conceptual model than threads that might lead to more maintainable code. It can also make your code easier to test, as you can write test scripts that exercise these external processes without having to involve the GUI. Some might even argue that is the primary advantage.
In the case of some code I once worked on, switching from threads to separate processes led to a net reduction of over 5000 lines of code while at the same time making the GUI more responsive, the code easier to maintain and test, all while improving the total overall performance.
|
148,963 |
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.
[Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways:
1. Use threads
2. Use wxYield
3. Chunk the work and do it in the IDLE event handler
Which method have *you* found to be the most effective ? Techniques from other frameworks (like Qt, GTK or Windows API) are also welcome.
|
2008/09/29
|
[
"https://Stackoverflow.com/questions/148963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] |
Threads or processes depending on the application. Sometimes it's actually best to have the GUI be it's own program and just send asynchronous calls to other programs when it has work to do. You'll still end up having multiple threads in the GUI to monitor for results, but it can simplify things if the work being done is complex and not directly connected to the GUI.
|
This answer doesn't apply to the OP's question regarding Python, but is more of a meta-response.
The easy way is threads. However, not every platform has pre-emptive threading (e.g. BREW, some other embedded systems) If possibly, simply chunk the work and do it in the IDLE event handler.
Another problem with using threads in BREW is that it doesn't clean up C++ stack objects, so it's way too easy to leak memory if you simply kill the thread.
|
148,963 |
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.
[Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways:
1. Use threads
2. Use wxYield
3. Chunk the work and do it in the IDLE event handler
Which method have *you* found to be the most effective ? Techniques from other frameworks (like Qt, GTK or Windows API) are also welcome.
|
2008/09/29
|
[
"https://Stackoverflow.com/questions/148963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] |
Threads. They're what I always go for because you can do it in every framework you need.
And once you're used to multi-threading and parallel processing in one language/framework, you're good on all frameworks.
|
I think `delayedresult` is what you are looking for:
<http://www.wxpython.org/docs/api/wx.lib.delayedresult-module.html>
See the wxpython demo for an example.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.