Read File in GWT server side - java

I need to read a properties file in the server-side of a GWT application.
I've tried to put the file in the root of the application and into the src folder. However, in both tries, A FileNotFound exception is thrown.
I create the file using the following code:
File file = new File("errors.properties");
Is it wrong? Where should I put the file?

into your war folder. I suppose you use Eclipse and integrated Google plugin to generate the app and also to run it.

You have to read the properties in your server side code and then send it to your GWT code. See this page for server-client communication. The file itself should probably be in your war folder. Also you cannot use File in your GWT code as it is not a supported emulated JRE library class. See here for supported library classes available in GWT.

Related

What generated my "appengine-web.xml" file?

I inherited a Java app that is configured to run in Google App Engine. My pom includes the com.google.appengine.appengine-maven-plugin plugin, which may or may not be related to this question.
In my src directory, in the WEB-INF directory, I have a "app.yaml" file. But when my project is built into a war, the target directory has both a "app.yaml" file and a "appengine-web.xml" file. How did this "appengine-web.xml" file get here?
The first line of this "appengine-web.xml" file says <!-- Generated from app.yaml. Do not edit. -->. If this file was generated from an "app.yaml" file, then what generated it? Which plugin/function has created this file?
As mentioned in the official documentation appengine-web.xml Reference:
App Engine Java applications use a configuration file, named appengine-web.xml, to specify information about your app and to identify which files in the app's WAR file are static files (like images) and which are resource files used by the application.
So, this is created by default, by the App Engine environment, when using the App Engine Maven plugin, so you can handle some specific settings and configurations. You can find more details on these settings here, but it includes the setting of environment variables, how to scale the application - manual, basic or automatic - etc. In addition to that, you can check this example of a sample app that is deployed into war and the file is created as well. Please, bear in mind that this is only on Java 8.
To summarize, this file is created by the App Engine environment when using this plugin, not by a specific function. In this official documentation here, it indicates this as well:
The artifact you used to create the project has done the basic src/main/webapp/WEB-INF/appengine-web.xml configuration for you
So, this confirms that it was created via the plugin. Besides that, it shows the message of the relation with app.yaml, because they work together and each one of them has a specific use and settings that are needed for your application to work correctly.
Let me know if the information helped you!
This was a non-documented feature of App Engine Maven Plugin that was removed about two years ago.
https://github.com/GoogleCloudPlatform/app-maven-plugin/issues/426#issuecomment-665757462

using a library file from within jar

This is a follow up of this question
What I try to do:
I have an eclipse project that uses th Sigar library in order to get the cpu information (among others). In order to do that Sigar needs a library file to work. Each CPU/OS have a different file, all of which are available.I have to pack this into a jar, that other can use my application as a library.
What I did:
added the available library files to my project and can access them like so
System.setProperty("org.hyperic.sigar.path",System.class.getResource("/lib").getPath());
System.load(System.class.getResource(getClass().getResource(
"/lib/libsigar-amd64-linux.so").toString()).getPath());
Both of these seems to work if i run my application as a stand alone application.
When i pack it to a jar and try to run it from an other project, it just doesn't work. I cant make it to see the directory or the file.
This is the structure of my project
I have tried to access the file with any path i could think of, but all returned a NullPointerException.
How can I do this? Using a temp file? I am not sure how i should do this, i would like to load the whole folder and not just one file, since i dont know the hardware/OS of the client application.

Website directory structure different from eclipse

I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly.
My eclipse directory structure on localhost is
Project Name
.src/packageName/java files
.WebContent/HTML files.
When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows,
. This will automatically trigger the java file in /src/packageName/welcome
When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?
Hmm...have you been sure to package the application as a war for deployment.

How to add class Source(src) class folder in Jsp Project Using Eclipse IDE

we have created Jsp Project, in that we had written Java class and use external jar file. Project is running fine in my local tomcat server, while when we deploy it in the main server we don't have access of web apps folder they gave me server access FTP and am sending that my project to that it deploying but only client side code run it show Error when server side code comes
http://www.incometaxindiapr.gov.in/incometaxindiacr/cbdt-cir-not/Home.jsp please check this
class file not compile
i think i am Unable to add class file please help how to add class file an all.
If it runs locally and not able to run while deploying to Server, then first thing what I think you should check is, when you transfer your war to server using FTP at that place only, WAR which is transferred is in correct format,
I mean whether .class files are all transferred and in classes folder only. if all this is correct check versions mismatch. rest can be checked by logs only.

How to add or use .DDL file in netbeans platform app

I'm making App in Netbeans platform in Java Swing. I want to add and use .DDL file in my App's module.
How can I do that?
how to make .jar file which contain .DDL file?
Add it to a Jar that is on the run-time class-path of the app. Here is a Netbeans tutorial for adding an image - the process is much the same for any non source file.
Access the file by URL or InputStream. Here is an example of getting an URL.
URL urlToResource = this.getClass().getResource("/path/to/the.ddl");
The mention of VC++ and JNI makes me think you are talking about a .DLL file.
In that case, it seems there is a simple solution.

Categories

Resources