I have a small issue with my code where im encrypting and decrypting messages.
My import org.apache.commons.codec.binary.Base64;. does not work.
It says binary does not exist_ Why this happens?. I've downloaded the codec but im starting to wonder if it has to do with where the codec folder is located, but i may be wrong.
I'm getting a Base64 encoded String of raw PDF data from a web service. I have to use this data display the PDF in a PDF viewer (I happen to be using the included 'ThinkFree PDF Viewer' since I'm working on an Android application, but the Android forum doesn't seem to get much traffic, so lets generalize and say any PDF viewer will do).
My code:
File file; FileOutputStream outputStream;
public void createFile() { try { File path = new File(getFilesDir(), "PDFs"); if (!path.exists()) { path.mkdirs();
[code]....
The error: Error opening file. It does not exist or cannot be read.
I am trying to make a jar file in intelliJ. My directory that holds all the java classes is C:rafficProjectsrccege. In cege there is a package ui where there is a class GuiMain. And I have imported the GuiMain() in my Main() class.
I have this code lines:
package cege; import cege.ui.GuiMain;
and when I use the terminal in the intelliJ and write the command:
C: rafficProjectsrccege>javac *.java
I get this message:
Main.java:3: error: package cege.ui does not exist
import cege.ui.GuiMain;
but actually, I have already put this line in my code. what could be the problem?
-getting words from dictionary text file and inserting them into a hash table - DONE -getting words from a usertext file and inserting them into a red-black tree - STUCK -after that i need to see if there is nodes of words that dosen't exist in the dictionary and print if so
kinda like a spelling checker
OK so the main code that hold the reading and storing part of dictionary and inserting to hash table
I am kind of new to programming in java and I am trying to run a first time setup type of thing for my program so I am saving the settings to a file. If the file doesn't exist I want it to run the first time setup but if the file does exist I want it to skip that process. My problem is that .exists() says reads true whether the file is there or is not there.
public static void main(String[] args)throws IOException{ new Window(); //Runs the Window() PrintWriter writer = new PrintWriter(path); boolean bool = new File("path.txt").exists(); System.out.println(bool); if(!new File("path.txt").exists()){
If I'm checking using an if statement if a file exists like so:
public boolean export(String envName,String fromFile,String toFile) { Vector<String> vector = new Vector<String>(); File file = new File(fromFile); if(file.exists() && file !=null) { return true; } return false;
If it returns true for existing then how would I do another if statement that would say if file returned true then check said file for an id. If Id exists extract all data associated with that id and store in Vector object. Would it be like this:
I am just trying to test this array, for a locker combination program that involves classes...but the array is printing out the whacky numbers for the location. When I try to call the method in the main, it does not work. How do I call a method that exist within a class into the main method?
public class locker { public static void main(String[] args) { CombinationLock();
how to differ between fields that are not exists to fields that are null? because in my api when someone wants to delete a field he sends null instead of a value. and if he doesnt want to effect this feild he doesnt send it.
i am migrating my web application from Server1 (Tomcat 5 and Java 1.5) to Server2 (Tomcat 7 wand Java 1.6).
In my web application, I have multiple adapters (web clients) that are connecting to external web services, https interfaces, sftp servers etc.
In order to connect with all these external interfaces, i have installed multiple certificates in my JRE keystore on Server1.
Now since the application is going to be migrated to Server2, i need to know if there is any way I can import all the existing certificates from Server1 JRE to Server2 JRE?
Since the application has been running on Server1 for a long time, I am not sure, what exactly is a complete list of certificates that I need to install on my Server2 JRE.
So i am kind of looking how can i generate the keystore file with certificates from the existing server1 JRE and then import it into Server2 JRE.
Does this command provide a list of all the installed certificates on my Server1 JRE?
The other solution i can think of is to manually download/save all the certificates by opening all the URLs in the browser and then import the .pfx files through keytool into my Server2 JRE.
how to make a simple game. I am having trouble when it comes to adding sound though. It tells me to do this:
package net.game.Game;
import java.applet.Applet; import java.applet.AudioClip; public class Sound { public static final AudioClip BALL = Applet.newAudioClip(Sound.class.getResource("ball.wav")); public static final AudioClip GAMEOVER = Applet.newAudioClip(Sound.class.getResource("gameover.wav")); public static final AudioClip BACK = Applet.newAudioClip(Sound.class.getResource("back.wav")); }
What this does is it gets the sound file then gives it a name(BALL=ball.wav GAMEOVER=gameover.wav ect..) and then there is other code in other classes that call the sound so it will run but it keeps giving me an error and I don't know what to do. How can I get it to import the sound? Here is the error.
PHP Code:
Exception in thread "main" java.lang.ExceptionInInitializerError at net.game.Game.stuff.<init>(stuff.java:35) at net.game.Game.stuff.main(stuff.java:62) Caused by: java.lang.NullPointerException at sun.applet.AppletAudioClip.<init>(Unknown Source) at java.applet.Applet.newAudioClip(Unknown Source) at net.game.Game.Sound.<clinit>(Sound.java:7) ... 2 more
I'm making an import/export of xml - I have the import of xml sorted I'm just trying to finish off the export. My export class is called XmlWriter.java. Inside the class I have an updateFile method to update an xml file as such:
public void updateFile(Environment environment,Document doc) { // code }
I then in my main method have
public static void main(String argv[]){ //declare new object of class XmlWriter xmlWriter = new XmlWriter(); //test testUpdate method // xmlWriter.testUpdate(); Environment environment = ;
[code]....
I don't know what to make my variables equal to - eclipse keeps trying to use null but obviously that won't work. The Environment is another class that just contains getters and setters for the 3 different databases (that are in the xml file) and the getter/setter for the environment ID (also in xml file).
Often times i don't remember which package a specific class (like ArrayList) belongs to. Is there an easy way to find that java.util.* is what i need to import, if i wanted to use the class ArrayList ?
I have imported several maven projects but I am trying to import a spring project via eclipse and it is not displaying. I did the following file->import->Existing maven projects->browse (found my project)->finish..... The project does not display and I cannot find it. I tired to do it again and the project cannot import because I cannot select it meaning it is already installed.
I am still playing around with decks of cards, and am now trying to implement some visualizations using Applets.
Here is how I enter my deck of cards into an array list: this works just fine:
String[] Suits = new String[]{"S","H","D","C"}; String[] Values = new String[]{"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; ArrayList<String> deck = new ArrayList<String>(); for(String suit : Suits) { for(String value : Values) { deck.add(suit+"_"+value); } }
The end result of this is an array 'deck' which contains a string representing each of the 52 playing cards. Great.
Now I would also like to use some pictures for future implementations I am working on. I have 52 images (.png, though I doubt it matters) stored in the right place. They are named as "H_5.png", and "S_A.png", for example, just as I named the cards in the previous array. I would like to do something as follows
ArrayList<Image> deckpic = new ArrayList<Image>(); for(String suit : Suits) { for(String value : Values) { deckpic.add(getImage(suit+"_"+value+".png")); } }
Now of course this doesn't work. The line
suit+"_"+value+".png"
is a string, not the name of a file. How I have previously loaded images is to use something like this:
the_pic = getImage("picture_of_pony.jpg");
but of course I can't use the quotations in my card loop, since I want "suit" and "value" to range and not just be the strings suit and value.
This code doesn't recognise the package ( and therefore class ) timetest3, when I try to import it. The package I try to reference/call, follows, and works fine.
import javax.swing.JOptionPane; import timetest3.TimeTest3; public class timetest4 { public static void main(String args[]) { TimeTest3 time = new TimeTest3(); time.setTime(13,45,52);
I have written a library in one project but cannot seem import to import it into my main project whenever I try Maven says it cant find it though it is installed in the repository and the .jar file is in the classpath.
Stack trace org.jclarion.clarion.lang.ClarionCompileError: Class Not Found:com.MyProj.app.MyClass near line:310 (selma012.clw) at org.jclarion.clarion.lang.Lexer.error(Lexer.java:190) at org.jclarion.clarion.compile.grammar.AbstractParser.error(AbstractParser.java:111) at org.jclarion.clarion.compile.grammar.AbstractParser.importJava(AbstractParser.java:463) at org.jclarion.clarion.compile.grammar.AbstractParser.emptyLex(AbstractParser.java:258)
I am trying to write a program, which includes an import data option. This option is used to import information from a text file.
The data is read from the file and objects are created and added to the student's record (The text file contains some information of the courses that the student is taking).
So my question is, how do i import information from a text file ?
and after they are imported, how do i create the objects in order to add them to the student's record ?