javax.microedition.io.file does not exist in BlueJ - java-me

Trying j2me app development. I got a simple Hello to work, and a simple TextBox user as well. But when I tried to compile code for a file browser I got "javax.microedition.io.file does not exist".
The WTK according to the Sun website is supposed to include JSR75. And there's a camera demo .java file that uses it.
I've looked in various places (the WTK, BlueJ, even Netbeans) for menu options to turn it on. Nothing. And a search of this forum turned up exactly ONE message and it pertains to another IDE, and it seemed to work for him in BlueJ.
So what am I missing and how do I get it?

In NetBeans, you go to Project Properties (right-click the project, and select Properties). Then click "Platform" and mark "File Connection and PIM Optional Packages 1.0".

On a whim I did a search for JSR75 jar download and found a few zipped jar files that seemed to contain the file classes. I unzipped one of them and put it in the Libraries/Userlib directory of BlueJ; and now I seem to have the File... Classes. Reading and writing seem to work in the emulator.
I'll take another look at Netbeans when I get a chance.

Related

how to create layout folder depending on api version?

i want to Create different layout depending api version as follows. Since the default folder layout is already available,when i create new layout as below screenshot it doesnt apppear in android studio folder list under res. but i right click on res and open with explorer those folder does shows. can any one please help me how to create those layout folder.
/res/layout/layout.xml (Default)
/res/layout-v14/layout.xml (Api 19)
/res/layout-v17/layout.xml (API 21)
I think the reason for not seeing the folders is due to the current viewing option you have selected in Android Studio. (please refer to the image below)
When Android is selected the folders are more compact, meaning it will focus on showing a single resource/folder regardless of qualifiers and I think that's what you experience. Switching to Project would solve it however.
This viewing option does have some great benefits by the way, for example I really love how gradle scripts are grouped together and it even shows the Global gradle.properties file (at least on MacOS) which it doesn't in Project view.

Content_Main and Activity_Main in Android Studio 1.4: If I put a button in activity_main, but not content_main, will the java file know about it?

I'm a beginner to android but have done a little with an older version of Android Studio, and in the new version I'm having a lot of trouble getting the java file to find buttons or ImageViews. I'm not sure if it's related to the content_main vs activity_main thing. I'm having trouble finding any answers as to how this works on Google, so I'm just starting here, I want to put a button on the main page of my app and have the java file that correlates to the XML file find it. How do I do this?
Answers online are very vague to me, things like "activity_main.xml will determine how the look of the main activity should be. And on the other hand content_main.xml will determine the contents in the activity_main.xml" does not mean anything to me. Please tell me where to put the button!
If you are adding a button in activity_main rather than content_main it cannot be recognized by your Java file. Not only that is will even not be visible on your app.

Cannot find the create package menu in Android Studio

I have a trouble to add a package under one of the flavor folder in Android Studio: after I right click on the java folder and I could not see the 'Package' or 'Java Classes' options there!
I did exactly the same for another flavor and it was fine.. Now I am stuck here, without knowing if it is a bug in AS or I did anything there. Anyone help me please!
(I googled it and did not solve it with what I have found so far)
=======EDIT========
I close the project and create a brand new empty project, now even in the main folder I cannot find the 'Java Classes' or 'Package' when I right click on the java folder I added.
However, if I just create the folders of the package under java with a class there, and do a build, it will finally recognize that and make java blue color and then I am able to see the menus if I right click the blue java folder.
So it sounds like some bug in AS.
It might just be the build flavor you are currently selected correctly to enable that flavor.
If we have two build flavor let's say free and pro. If pro is selected is current build flavor. The flavor free will not be shown as java package in blue color as you mentioned, it will be shown as directory structure. Hence change the build variant and make it workable.
Not sure if you faced the same issue, but sharing it for reference of others who might face this issue as i faced now.
Package option is available only for selected flavor. switch to desired flavor and IDE will refer that source directory and will convert it to package and directories from other flavors will be listed as normal directories tree structure.
I found this Solution.
File > Project Structure > Select the lib folder > Click on Sources > Apply and Okay
Now you can see the new package option by right clicking the lib folder, the new package option will be shown.
Step1
Step2
Step3
Control click (mac), or right click the /java directory and select Mark Directory As -> Source Root. You should then be able to right click the /java directory and select -> New -> Package. Your java directory will also appear blue.
Solution. File- Project Structure- Modules- Right click on lib - Select Sources.
then the option "Package" will appear on your list.

Rename Android Studio project causing a bunch of errors and java files missing

Following some links here I tried to rename a project. I went to c:\path\to\AndroidStudioProject and renamed the folder there, then found the .idea file and changed that. Now the project loads but java files are missing! However, on clicking java (in the bar at the top), then com I can see them each with a small red j.
I then looked in module Gradle build where there were 3 files, one with the new name and 2 older ones which stated that they did not belong so I deleted them, copying the compile info into the new one. Naturally on doing a Sync Now I get a bunch of errors.
Why does this have to be such a complex operation? Can anyone assist?
After you rename the folder, open the project in Android Studio. From there, right click something that needs to be renamed (e.g., module, package names, etc.) and use Refactor->Rename from the context menu. Keep doing this until everything that can be refactored is.
You will need to manually change the value of applicationId in the app-level build.gradle. Obviously, things like #string/app_name will also have to be changed manually. I recommend making these manual adjustments from inside Android Studio rather than directly editing the files. That way you'll know immediately if you break something.

Renaming Controller classes in MonoTouch MonoDevelop

What is the the best way to rename a class which inherits a UIViewController and has a designer.cs class linked to a storyboard?
I first tried to Rename the .cs file in MonoDevelop. This worked but the designer.cs file did not get renamed with it, and neither did the class name.
I then renamed the class name. This successfully changed the class name in both the .cs and .designer.cs files but still did not change the .designer.cs filename. It also did not change the name of the "Custom Class" for the controller in Xcode.
So in XCode I changed the name of the Custom Class and saved then switched back to MonoDevelop , to my horror it had created a new .cs with the same name as the renamed one and a new .designer.cs file which it put under the original (renamed) .cs file next to the old (not renamed) a.designer.cs file!
Can anyone tell me the sequence of steps I should have taken?
Renaming the file is tricky, since MD doesn't support renaming grouped files. You'd have to manually edit the csproj, or remove the files from the project, rename in Finder, and add them back.
Renaming the class is somewhat easier, but the key is to understand that the class actually has two names - the .NET name, and the Obj-C name. Renaming the .NET name should be easy, you can simply use the rename command in MD.
The Obj-C name is applied to the class on the [Register("SomeName")] attribute, and is the name that's used in xibs and in Xcode. However, beware that MonoDevelop will attempt to create .NET counterparts of any classes that it thinks were created in Xcode. This means you should change the Obj-C name in MonoDevelop first, then switch to Xcode and change the Custom Class there.
You have to go into the .csproj file and add a tag. For example:
<Compile Include="MainWindow.cs" />
<Compile Include="MainWindow.designer.cs">
<DependentUpon>MainWindow.cs</DependentUpon>
</Compile>
This will then show the correct relationship between the files in the MonoDevelop project window.
Incidentally, my experience so far is that this dependency is purely for convenience. Add the new designer.cs file into the solution and the code compiles just fine: dependency seems to be a sort of documentation.
ALSO: To delete or rename these dependent files, you can't do that in the MonoDevelop project pane: you do have to go to Finder (if you're in OSX, Explorer if you're in Windows) and deal with the files there, to rename or otherwise manipulate them, THEN repair the MonoDevelop csproj file by hand. The good news is, it's not hard, and it works fine when you do this, and you get a cool new hardcore understanding about how the project is knit together.
Many people also has to think about the version control system. This way works for me:
Quit MonoDevelop
In the version control system, rename the files
Open the csproj file in a text editor - search&replace
Open MonoDevelop
Open the XxxViewController.cs - search&replace
Open the XxxViewController.designer.cs - search&replace
Open the XxxViewController.xib - search&replace
You might be tempted to use Refactor/Rename instead of search & replace in step 5 but that will cause MonoDevelop to rename XxxViewController.designer.cs to XxxViewController_1.cs for some reason.
Also, you might be tempted to remove the files from the project before renaming them in the version control system and then add them back into your project again (so that you won't have to edit the csproj file manually). This will work but the "DependentUpon" part will disappear from the csproj file, which causes the designer file to not be below its counterpart. No big deal but it looks less nice in the Solution Explorer.
I tried all the solutions above and didn't work. Finally I just used the "Replace in Files" looking the whole solution. After that I did a "Rebuild" in the project and worked fine.

Resources